mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Merge "Update rel attribute checks to be aware of multiple rel values"
This commit is contained in:
commit
00eb598352
|
@ -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