mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Merge "Fix a few risky places for a multi-valued rel attributes"
This commit is contained in:
commit
012458f4ca
|
@ -20,7 +20,9 @@ ve.ce.MWExternalLinkAnnotation = function VeCeMWExternalLinkAnnotation( model )
|
|||
ve.ce.MWExternalLinkAnnotation.super.apply( this, arguments );
|
||||
|
||||
// DOM changes
|
||||
if ( model.getAttribute( 'rel' ) === 'mw:WikiLink/Interwiki' ) {
|
||||
var rel = model.getAttribute( 'rel' ) || '';
|
||||
var relValues = rel.split( /\s+/ );
|
||||
if ( relValues.indexOf( 'mw:WikiLink/Interwiki' ) >= 0 ) {
|
||||
this.$anchor.addClass( 'extiw' );
|
||||
} else {
|
||||
this.$anchor.addClass( 'external' );
|
||||
|
|
|
@ -210,7 +210,7 @@ ve.ce.MWTransclusionNode.prototype.getRenderedDomElements = function () {
|
|||
*/
|
||||
ve.ce.MWTransclusionNode.prototype.filterRenderedDomElements = function ( domElements ) {
|
||||
// We want to remove all styles and links which aren't from TemplateStyles.
|
||||
var selector = 'style:not([data-mw-deduplicate^="TemplateStyles:"]), link:not([rel="mw-deduplicated-inline-style"][href^="mw-data:TemplateStyles:"])';
|
||||
var selector = 'style:not([data-mw-deduplicate^="TemplateStyles:"]), link:not([rel~="mw-deduplicated-inline-style"][href^="mw-data:TemplateStyles:"])';
|
||||
return $( domElements ).find( selector ).addBack( selector ).remove().end().end().toArray();
|
||||
};
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ ve.dm.MWExternalLinkAnnotation.static.toDomElements = function ( dataElement, do
|
|||
domElements[ 0 ].setAttribute( 'class', 'external' );
|
||||
}
|
||||
|
||||
// we just created that link so the 'rel' attribute should be safe
|
||||
domElements[ 0 ].setAttribute( 'rel', dataElement.attributes.rel || 'mw:ExtLink' );
|
||||
return domElements;
|
||||
};
|
||||
|
|
|
@ -108,6 +108,7 @@ ve.dm.MWInternalLinkAnnotation.static.newFromTitle = function ( title, rawTitle
|
|||
|
||||
ve.dm.MWInternalLinkAnnotation.static.toDomElements = function () {
|
||||
var parentResult = ve.dm.LinkAnnotation.static.toDomElements.apply( this, arguments );
|
||||
// we just created that link so the 'rel' attribute should be safe
|
||||
parentResult[ 0 ].setAttribute( 'rel', 'mw:WikiLink' );
|
||||
return parentResult;
|
||||
};
|
||||
|
|
|
@ -100,7 +100,7 @@ mw.libs.ve.stripRestbaseIds = function ( doc ) {
|
|||
* @param {HTMLElement} element Parent element, e.g. document body
|
||||
*/
|
||||
mw.libs.ve.reduplicateStyles = function ( element ) {
|
||||
Array.prototype.forEach.call( element.querySelectorAll( 'link[rel="mw-deduplicated-inline-style"]' ), function ( link ) {
|
||||
Array.prototype.forEach.call( element.querySelectorAll( 'link[rel~="mw-deduplicated-inline-style"]' ), function ( link ) {
|
||||
var href = link.getAttribute( 'href' );
|
||||
if ( !href || href.slice( 0, 'mw-data:'.length ) !== 'mw-data:' ) {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue