mediawiki-extensions-Visual.../modules/ve/dm/nodes/ve.dm.TableCaptionNode.js
Roan Kattouw c68765639a Add TableCaptionNode
Because we have a node for <table>, we also need one for <caption>,
otherwise we'll try to alienate it and fail.

Added the test case as a separate example document so Ed can use it
for his tests.

Removed test case asserting <caption> is alienated.

Change-Id: I3a917db58e6c0eb97899b214b07d01fc8d86b56d
2013-04-26 14:09:54 -07:00

45 lines
1.1 KiB
JavaScript

/*!
* VisualEditor DataModel TableCaptionNode class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* DataModel table caption node.
*
* @class
* @extends ve.dm.BranchNode
* @constructor
* @param {ve.dm.BranchNode[]} [children] Child nodes to attach
* @param {Object} [element] Reference to element in linear model
*/
ve.dm.TableCaptionNode = function VeDmTableCaptionNode( children, element ) {
// Parent constructor
ve.dm.BranchNode.call( this, children, element );
};
/* Inheritance */
ve.inheritClass( ve.dm.TableCaptionNode, ve.dm.BranchNode );
/* Static Properties */
ve.dm.TableCaptionNode.static.name = 'tableCaption';
ve.dm.TableCaptionNode.static.parentNodeTypes = [ 'table' ];
ve.dm.TableCaptionNode.static.matchTagNames = [ 'caption' ];
ve.dm.TableCaptionNode.static.toDataElement = function () {
return { 'type': 'tableCaption' };
};
ve.dm.TableCaptionNode.static.toDomElements = function ( dataElement, doc ) {
return [ doc.createElement( 'caption' ) ];
};
/* Registration */
ve.dm.modelRegistry.register( ve.dm.TableCaptionNode );