mediawiki-extensions-Visual.../modules/ve/ce/ve.ce.NodeFactory.js
Ed Sanders edcaaf9edc Use static.name once for ce and dm nodes
Add a static.name property to ce nodes and make sure both ce
and dm nodes always use the static.name property in constructors
and registration calls.

The result of this is that any given node type should now only
appear once in the code as a string.

Bug: 45701
Change-Id: Ibf31de16ab28ad58209c1443cd74f93dda278998
2013-03-07 17:19:39 -08:00

44 lines
967 B
JavaScript

/*!
* VisualEditor ContentEditable NodeFactory class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* ContentEditable node factory.
*
* @class
* @extends ve.NodeFactory
* @constructor
*/
ve.ce.NodeFactory = function VeCeNodeFactory() {
// Parent constructor
ve.NodeFactory.call( this );
};
/* Inheritance */
ve.inheritClass( ve.ce.NodeFactory, ve.NodeFactory );
/* Methods */
/**
* Check if a node type can be split.
*
* @param {string} type Node type
* @returns {boolean} The node can have grandchildren
* @throws {Error} Unknown node type
*/
ve.ce.NodeFactory.prototype.canNodeBeSplit = function ( type ) {
if ( type in this.registry ) {
return this.registry[type].static.canBeSplit;
}
throw new Error( 'Unknown node type: ' + type );
};
/* Initialization */
// TODO: Move instantiation to a different file
ve.ce.nodeFactory = new ve.ce.NodeFactory();