Merge "Make RDF attribute splits more robust"

This commit is contained in:
jenkins-bot 2018-10-03 20:12:10 +00:00 committed by Gerrit Code Review
commit 3f1626c4f9
5 changed files with 5 additions and 5 deletions

View file

@ -39,7 +39,7 @@ ve.dm.MWExternalLinkAnnotation.static.toDataElement = function ( domElements, co
var dataElement, annotation,
domElement = domElements[ 0 ],
type = domElement.getAttribute( 'rel' ) || domElement.getAttribute( 'typeof' ) || domElement.getAttribute( 'property' ) || '',
types = type.split( ' ' );
types = type.trim().split( /\s+/ );
// If the link doesn't have a known RDFa type, auto-convert it to the correct type (internal/external/span)
if ( types.indexOf( 'mw:ExtLink' ) === -1 && types.indexOf( 'mw:WikiLink/Interwiki' ) === -1 ) {

View file

@ -76,7 +76,7 @@ ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter
img = imgWrapper.children[ 0 ]; // <img>, <video> or <audio>
captionNode = figure.children[ 1 ]; // <figcaption> or undefined
classAttr = figure.getAttribute( 'class' );
typeofAttrs = figure.getAttribute( 'typeof' ).split( ' ' );
typeofAttrs = figure.getAttribute( 'typeof' ).trim().split( /\s+/ );
mwDataJSON = figure.getAttribute( 'data-mw' );
mwData = mwDataJSON ? JSON.parse( mwDataJSON ) : {};
errorIndex = typeofAttrs.indexOf( 'mw:Error' );

View file

@ -29,7 +29,7 @@ ve.dm.MWGalleryCaptionNode.static.matchTagNames = [ 'li' ];
ve.dm.MWGalleryCaptionNode.static.matchFunction = function ( element ) {
var parentTypeof = ( element.parentNode && element.parentNode.getAttribute( 'typeof' ) ) || '';
return element.getAttribute( 'class' ) === 'gallerycaption' &&
parentTypeof.split( ' ' ).indexOf( 'mw:Extension/gallery' ) !== -1;
parentTypeof.trim().split( /\s+/ ).indexOf( 'mw:Extension/gallery' ) !== -1;
};
ve.dm.MWGalleryCaptionNode.static.parentNodeTypes = [ 'mwGallery' ];

View file

@ -35,7 +35,7 @@ ve.dm.MWGalleryImageNode.static.childNodeTypes = [ 'mwGalleryImageCaption' ];
ve.dm.MWGalleryImageNode.static.matchFunction = function ( element ) {
var parentTypeof = ( element.parentNode && element.parentNode.getAttribute( 'typeof' ) ) || '';
return element.getAttribute( 'class' ) === 'gallerybox' &&
parentTypeof.split( ' ' ).indexOf( 'mw:Extension/gallery' ) !== -1;
parentTypeof.trim().split( /\s+/ ).indexOf( 'mw:Extension/gallery' ) !== -1;
};
ve.dm.MWGalleryImageNode.static.parentNodeTypes = [ 'mwGallery' ];

View file

@ -55,7 +55,7 @@ ve.dm.MWInlineImageNode.static.toDataElement = function ( domElements, converter
figureInline = domElements[ 0 ],
imgWrapper = figureInline.children[ 0 ], // <a> or <span>
img = imgWrapper.children[ 0 ], // <img>, <video> or <audio>
typeofAttrs = ( figureInline.getAttribute( 'typeof' ) || '' ).split( ' ' ),
typeofAttrs = ( figureInline.getAttribute( 'typeof' ) || '' ).trim().split( /\s+/ ),
mwDataJSON = figureInline.getAttribute( 'data-mw' ),
mwData = mwDataJSON ? JSON.parse( mwDataJSON ) : {},
classes = figureInline.getAttribute( 'class' ),