mediawiki-extensions-Visual.../modules/ve2/dm/ve.dm.TwigNode.js
Trevor Parscal 7ea475ebcf Initial commit of data model rewrite
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
2012-04-19 13:54:34 -07:00

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 );