Merge "Update rel attribute checks to be aware of multiple rel values"

This commit is contained in:
jenkins-bot 2018-03-09 21:44:53 +00:00 committed by Gerrit Code Review
commit 00eb598352
2 changed files with 8 additions and 4 deletions

View file

@ -35,10 +35,14 @@ ve.dm.MWExternalLinkAnnotation.static.name = 'link/mwExternal';
ve.dm.MWExternalLinkAnnotation.static.matchFunction = function ( domElement ) {
var type = domElement.getAttribute( 'rel' ) || domElement.getAttribute( 'typeof' ) || domElement.getAttribute( 'property' );
// Match explicity mw:ExtLink (external links), mw:WikiLink/Interwiki
// Match explicitly mw:ExtLink (external links), mw:WikiLink/Interwiki
// (interwiki links), or plain RDFa-less links with an href
// (e.g. from external paste)
return ( !type && domElement.hasAttribute( 'href' ) ) || type === 'mw:ExtLink' || type === 'mw:WikiLink/Interwiki';
if ( type ) {
type = type.split( ' ' );
return type.indexOf( 'mw:ExtLink' ) !== -1 || type.indexOf( 'mw:WikiLink/Interwiki' ) !== -1;
}
return domElement.hasAttribute( 'href' );
};
ve.dm.MWExternalLinkAnnotation.static.toDataElement = function ( domElements, converter ) {

View file

@ -195,7 +195,7 @@ ve.ui.MWSaveDialog.prototype.showPreview = function ( docOrMsg, baseDoc ) {
if ( docOrMsg instanceof HTMLDocument ) {
// Extract required modules for stylesheet tags (avoids re-loading styles)
Array.prototype.forEach.call( docOrMsg.head.querySelectorAll( 'link[rel=stylesheet]' ), function ( link ) {
Array.prototype.forEach.call( docOrMsg.head.querySelectorAll( 'link[rel~=stylesheet]' ), function ( link ) {
var uri = new mw.Uri( link.href );
if ( uri.query.modules ) {
modules = modules.concat( ve.expandModuleNames( uri.query.modules ) );
@ -208,7 +208,7 @@ ve.ui.MWSaveDialog.prototype.showPreview = function ( docOrMsg, baseDoc ) {
mw.loader.using( modules );
body = docOrMsg.body;
// Take a snapshot of all categories
Array.prototype.forEach.call( body.querySelectorAll( 'link[rel="mw:PageProp/Category"]' ), function ( element ) {
Array.prototype.forEach.call( body.querySelectorAll( 'link[rel~="mw:PageProp/Category"]' ), function ( element ) {
categories.push( ve.dm.MWCategoryMetaItem.static.toDataElement( [ element ] ).attributes.category );
} );
// Import body to current document, then resolve attributes against original document (parseDocument called #fixBase)