mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
7ea475ebcf
Ground-up rewrite of the data model. Putting this in the ve2 directory for now so we still have the old code floating around. Main changes so far in this rewrite: * Renamed hasChildren() to canHaveChildren() * Added canHaveGrandchildren() * Added a new node type TwigNode that can have children but not grandchildren (so all of its children must be LeafNodes) * Implemented push/pop/shift/unshift as wrappers around splice() * Renamed getElementType() to getType(). Nodes now take a string as a type, and the element stuff is gone and won't be back * Removed clearRoot(), replaced it with setRoot( this ) where needed Change-Id: I23f3bb1b4a2473575e5446e87fdf17af107bacf6
25 lines
635 B
JavaScript
25 lines
635 B
JavaScript
/**
|
|
* Data model node that can have leaf children.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
* @constructor
|
|
* @extends {ve.TwigNode}
|
|
* @extends {ve.dm.BranchNode}
|
|
* @param {String} type Symbolic name of node type
|
|
* @param {Array} [children] Child nodes to attach
|
|
* @param {Object} [attributes] Reference to map of attribute key/value pairs
|
|
*/
|
|
ve.dm.TwigNode = function( type, children, attributes ) {
|
|
// Inheritance
|
|
ve.TwigNode.call( this );
|
|
ve.dm.BranchNode.call( this, type, children, attributes );
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/* Inheritance */
|
|
|
|
ve.extendClass( ve.dm.TwigNode, ve.dm.BranchNode );
|
|
ve.extendClass( ve.dm.TwigNode, ve.TwigNode );
|