mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-19 09:41:09 +00:00
dbc696124f
Temporarily disable prefer-const as this requires manual fixing. Change-Id: I477b69a57e8d33535c6fc71dba196a8605780725
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel MWGalleryCaptionNode class.
|
|
*
|
|
* @copyright See AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* DataModel gallery caption node.
|
|
*
|
|
* @class
|
|
* @extends ve.dm.BranchNode
|
|
*
|
|
* @constructor
|
|
* @param {Object} [element] Reference to element in linear model
|
|
* @param {ve.dm.Node[]} [children]
|
|
*/
|
|
ve.dm.MWGalleryCaptionNode = function VeDmMWGalleryCaptionNode() {
|
|
// Parent constructor
|
|
ve.dm.MWGalleryCaptionNode.super.apply( this, arguments );
|
|
};
|
|
|
|
OO.inheritClass( ve.dm.MWGalleryCaptionNode, ve.dm.BranchNode );
|
|
|
|
ve.dm.MWGalleryCaptionNode.static.name = 'mwGalleryCaption';
|
|
|
|
ve.dm.MWGalleryCaptionNode.static.matchTagNames = [ 'li' ];
|
|
|
|
ve.dm.MWGalleryCaptionNode.static.matchFunction = function ( element ) {
|
|
const parentTypeof = ( element.parentNode && element.parentNode.getAttribute( 'typeof' ) ) || '';
|
|
return element.getAttribute( 'class' ) === 'gallerycaption' &&
|
|
parentTypeof.trim().split( /\s+/ ).indexOf( 'mw:Extension/gallery' ) !== -1;
|
|
};
|
|
|
|
ve.dm.MWGalleryCaptionNode.static.parentNodeTypes = [ 'mwGallery' ];
|
|
|
|
ve.dm.MWGalleryCaptionNode.static.toDomElements = function ( dataElement, doc ) {
|
|
const li = doc.createElement( 'li' );
|
|
li.classList.add( 'gallerycaption' );
|
|
return [ li ];
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWGalleryCaptionNode );
|