mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
Update rel attribute checks to be aware of multiple rel values
Various checks didn't think a rel attribute could contain multiple values. Mostly they don't, but to play it safe let's adjust the checks. Change-Id: I29823b7c8c65ef6b2ff41ce9a801840000972e9c Depends-On: I33a456351ab025d0c81cfb1a1577d5a2ae9df51a
This commit is contained in:
parent
f8c5608caf
commit
4e10d5b975
|
@ -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 ) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue