mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Merge "Remove conflicting section IDs in diff views"
This commit is contained in:
commit
3c7d81aa2f
|
@ -72,6 +72,8 @@
|
|||
var diffElement = new ve.ui.DiffElement( visualDiffGenerator(), { classes: [ 've-init-mw-diffPage-diff' ] } );
|
||||
diffElement.$document.addClass( 'mw-parser-output content' );
|
||||
|
||||
mw.libs.ve.fixFragmentLinks( diffElement.$document[ 0 ], mw.Title.newFromText( newPageName ), 'mw-diffpage-visualdiff-' );
|
||||
|
||||
progress.$element.addClass( 'oo-ui-element-hidden' );
|
||||
$visualDiff.append( diffElement.$element );
|
||||
lastDiff = {
|
||||
|
|
|
@ -127,6 +127,7 @@ mw.libs.ve.fixFragmentLinks = function ( container, docTitle, prefix ) {
|
|||
// hasn't already been fixed (in which case it would be null)
|
||||
if ( target ) {
|
||||
target.setAttribute( 'id', prefix + fragment );
|
||||
target.setAttribute( 'data-mw-id-fixed', '' );
|
||||
}
|
||||
}
|
||||
el.setAttribute( 'href', '#' + prefix + fragment );
|
||||
|
@ -136,6 +137,12 @@ mw.libs.ve.fixFragmentLinks = function ( container, docTitle, prefix ) {
|
|||
}
|
||||
}
|
||||
} );
|
||||
// Remove any section heading anchors which weren't fixed above (T218492)
|
||||
Array.prototype.forEach.call( container.querySelectorAll( 'h1, h2, h3, h4, h5, h6' ), function ( el ) {
|
||||
if ( el.hasAttribute( 'id' ) && !el.hasAttribute( 'data-mw-id-fixed' ) ) {
|
||||
el.removeAttribute( 'id' );
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue