mediawiki-extensions-Visual.../modules/ve-mw/dm/nodes/ve.dm.MWNumberedExternalLinkNode.js
James D. Forrester 2c00c39393 Update VE core submodule to master (2587549)
Update DM node constructors for I81c60d4a in VE core.

New changes:
2587549 [BREAKING CHANGE] Fix Node construction arguments

Change-Id: I8d4f37b631fe85a78c72407937477963ac49f87a
2014-06-06 20:28:03 -07:00

60 lines
1.6 KiB
JavaScript

/*!
* VisualEditor DataModel MWNumberedExternalLinkNode class.
*
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* DataModel MediaWiki numbered external link node.
*
* @class
* @extends ve.dm.LeafNode
*
* @constructor
* @param {Object} [element] Reference to element in linear model
*/
ve.dm.MWNumberedExternalLinkNode = function VeDmMWNumberedExternalLinkNode() {
// Parent constructor
ve.dm.LeafNode.apply( this, arguments );
};
/* Inheritance */
OO.inheritClass( ve.dm.MWNumberedExternalLinkNode, ve.dm.LeafNode );
/* Static Properties */
ve.dm.MWNumberedExternalLinkNode.static.name = 'link/mwNumberedExternal';
ve.dm.MWNumberedExternalLinkNode.static.isContent = true;
ve.dm.MWNumberedExternalLinkNode.static.matchTagNames = [ 'a' ];
ve.dm.MWNumberedExternalLinkNode.static.matchRdfaTypes = [ 'mw:ExtLink' ];
ve.dm.MWNumberedExternalLinkNode.static.matchFunction = function ( element ) {
// Must be empty
return element.childNodes.length === 0;
};
ve.dm.MWNumberedExternalLinkNode.static.toDataElement = function ( domElements ) {
return {
'type': this.name,
'attributes': {
'href': domElements[0].getAttribute( 'href' )
}
};
};
ve.dm.MWNumberedExternalLinkNode.static.toDomElements = function ( dataElement, doc ) {
var domElement = doc.createElement( 'a' );
domElement.setAttribute( 'href', dataElement.attributes.href );
domElement.setAttribute( 'rel', 'mw:ExtLink' );
return [ domElement ];
};
/* Registration */
ve.dm.modelRegistry.register( ve.dm.MWNumberedExternalLinkNode );