Merge "Use .static.isMeta to communicate meta-ness"

This commit is contained in:
jenkins-bot 2013-02-14 18:47:48 +00:00 committed by Gerrit Code Review
commit a1bd1db241
4 changed files with 32 additions and 1 deletions

View file

@ -29,6 +29,8 @@ ve.inheritClass( ve.dm.MetaNode, ve.dm.LeafNode );
ve.dm.MetaNode.static.name = 'meta';
ve.dm.MetaNode.static.isMeta = true;
ve.dm.MetaNode.static.matchTagNames = [ 'meta', 'link' ];
ve.dm.MetaNode.static.toDataElement = function ( domElement, context ) {

View file

@ -68,7 +68,10 @@ ve.dm.Document = function VeDmDocument( data, parentDocument ) {
// Track the length
textLength++;
} else {
if ( this.data[i].type === 'metaInline' || this.data[i].type === 'metaBlock' ) {
if (
this.data[i].type.charAt( 0 ) !== '/' &&
ve.dm.nodeFactory.isNodeMeta( this.data[i].type )
) {
// Metadata
// Splice the meta element and its closing out of the linmod
meta = this.data[i];

View file

@ -139,6 +139,17 @@ ve.dm.Node.static.toDomElement = function ( /*dataElement*/ ) {
throw new Error( 've.dm.Node subclass must implement toDomElement' );
};
/**
* Whether this node type represents metadata.
*
* Linear model elements with this type will be moved out of the linear model into the metadata.
*
* @static
* @property {Boolean} static.isMeta
* @inheritable
*/
ve.dm.Node.static.isMeta = false;
/**
* Whether this node type has a wrapping element in the linear model. Most node types are wrapped,
* only special node types are not wrapped.

View file

@ -109,6 +109,21 @@ ve.dm.NodeFactory.prototype.canNodeHaveGrandchildren = function ( type ) {
throw new Error( 'Unknown node type: ' + type );
};
/**
* Check if a node represents metadata.
*
* @method
* @param {string} type Node type
* @returns {boolean} The node is meta
* @throws {Error} Unknown node type
*/
ve.dm.NodeFactory.prototype.isNodeMeta = function ( type ) {
if ( type in this.registry ) {
return this.registry[type].static.isMeta;
}
throw new Error( 'Unknown node type: ' + type );
};
/**
* Check if a node has a wrapped element in the document data.
*