Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/dm/nodes/ve.dm.MWGalleryCaptionNode.js

raw symbols SCIP
1 /*!
2 * VisualEditor DataModel MWGalleryCaptionNode class.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * DataModel gallery caption node.
10 *
11 * @class
12 * @extends ve.dm.BranchNode
13 *
14 * @constructor
15 * @param {Object} [element] Reference to element in linear model
16 * @param {ve.dm.Node[]} [children]
17 */
18 ve.dm.MWGalleryCaptionNode = function VeDmMWGalleryCaptionNode() {
19 // Parent constructor
20 ve.dm.MWGalleryCaptionNode.super.apply( this, arguments );
21 };
22
23 OO.inheritClass( ve.dm.MWGalleryCaptionNode, ve.dm.BranchNode );
24
25 ve.dm.MWGalleryCaptionNode.static.name = 'mwGalleryCaption';
26
27 ve.dm.MWGalleryCaptionNode.static.matchTagNames = [ 'li' ];
28
29 ve.dm.MWGalleryCaptionNode.static.matchFunction = function ( element ) {
30 const parentTypeof = ( element.parentNode && element.parentNode.getAttribute( 'typeof' ) ) || '';
31 return element.getAttribute( 'class' ) === 'gallerycaption' &&
32 parentTypeof.trim().split( /\s+/ ).indexOf( 'mw:Extension/gallery' ) !== -1;
33 };
34
35 ve.dm.MWGalleryCaptionNode.static.parentNodeTypes = [ 'mwGallery' ];
36
37 ve.dm.MWGalleryCaptionNode.static.toDomElements = function ( dataElement, doc ) {
38 const li = doc.createElement( 'li' );
39 li.classList.add( 'gallerycaption' );
40 return [ li ];
41 };
42
43 /* Registration */
44
45 ve.dm.modelRegistry.register( ve.dm.MWGalleryCaptionNode );