mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
c2d4a2d928
* Also removed beforeSplice and afterSplice in favor of just plain splice which is the same as afterSplice used to be - beforeSplice was never used and it was making things more complex looking than needed Change-Id: Icbbc57eac73a2a206ba35409ab57b3d1a49ab1a5
62 lines
1.1 KiB
JavaScript
62 lines
1.1 KiB
JavaScript
/**
|
|
* Generic node.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
* @constructor
|
|
* @extends {ve.EventEmitter}
|
|
* @param {String} type Symbolic name of node type
|
|
*/
|
|
ve.Node = function( type ) {
|
|
// Inheritance
|
|
ve.EventEmitter.call( this );
|
|
|
|
// Properties
|
|
this.type = type;
|
|
this.parent = null;
|
|
this.root = this;
|
|
|
|
// Convenience function for emitting update events
|
|
// Has this bound to the closure scope, so can be passed as a callback
|
|
var _this = this;
|
|
this.emitUpdate = function() {
|
|
_this.emit( 'update' );
|
|
};
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Gets the symbolic node type name.
|
|
*
|
|
* @method
|
|
* @returns {String} Symbolic name of element type
|
|
*/
|
|
ve.Node.prototype.getType = function() {
|
|
return this.type;
|
|
};
|
|
|
|
/**
|
|
* Gets a reference to this node's parent.
|
|
*
|
|
* @method
|
|
* @returns {ve.Node} Reference to this node's parent
|
|
*/
|
|
ve.Node.prototype.getParent = function() {
|
|
return this.parent;
|
|
};
|
|
|
|
/**
|
|
* Gets the root node in the tree this node is currently attached to.
|
|
*
|
|
* @method
|
|
* @returns {ve.Node} Root node
|
|
*/
|
|
ve.Node.prototype.getRoot = function() {
|
|
return this.root;
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.extendClass( ve.Node, ve.EventEmitter );
|