Catrope has uploaded a new change for review. https://gerrit.wikimedia.org/r/50027
Change subject: Add MWMetaNode to clean up <meta>/<link> hack in the converter ...................................................................... Add MWMetaNode to clean up <meta>/<link> hack in the converter Change-Id: I4c69bff4981eef78415b43d31c3fd2ee271450ef --- M VisualEditor.php M demos/ve/index.php A modules/ve/dm/nodes/ve.dm.MWMetaNode.js M modules/ve/dm/nodes/ve.dm.MetaNode.js M modules/ve/dm/ve.dm.Converter.js M modules/ve/test/index.php 6 files changed, 44 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/27/50027/1 diff --git a/VisualEditor.php b/VisualEditor.php index 45a4e33..a83edd7 100644 --- a/VisualEditor.php +++ b/VisualEditor.php @@ -241,6 +241,7 @@ 've/dm/nodes/ve.dm.ListNode.js', 've/dm/nodes/ve.dm.MetaNode.js', 've/dm/nodes/ve.dm.MWEntityNode.js', + 've/dm/nodes/ve.dm.MWMetaNode.js', 've/dm/nodes/ve.dm.ParagraphNode.js', 've/dm/nodes/ve.dm.PreformattedNode.js', 've/dm/nodes/ve.dm.TableCellNode.js', diff --git a/demos/ve/index.php b/demos/ve/index.php index 85295dd..d5380e7 100644 --- a/demos/ve/index.php +++ b/demos/ve/index.php @@ -133,6 +133,7 @@ <script src="../../modules/ve/dm/nodes/ve.dm.ListNode.js"></script> <script src="../../modules/ve/dm/nodes/ve.dm.MetaNode.js"></script> <script src="../../modules/ve/dm/nodes/ve.dm.MWEntityNode.js"></script> + <script src="../../modules/ve/dm/nodes/ve.dm.MWMetaNode.js"></script> <script src="../../modules/ve/dm/nodes/ve.dm.ParagraphNode.js"></script> <script src="../../modules/ve/dm/nodes/ve.dm.PreformattedNode.js"></script> <script src="../../modules/ve/dm/nodes/ve.dm.TableCellNode.js"></script> diff --git a/modules/ve/dm/nodes/ve.dm.MWMetaNode.js b/modules/ve/dm/nodes/ve.dm.MWMetaNode.js new file mode 100644 index 0000000..1a24ec8 --- /dev/null +++ b/modules/ve/dm/nodes/ve.dm.MWMetaNode.js @@ -0,0 +1,40 @@ +/*! + * VisualEditor DataModel MWMetaNode class. + * + * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ + +/** + * DataModel MW-specific meta node. + * + * @class + * @abstract + * @extends ve.dm.MetaNode + * @constructor + * @param {string} name Node name + * @param {number} [length] Length of content data in document; ignored and overridden to 0 + * @param {Object} [element] Reference to element in linear model + */ +ve.dm.MWMetaNode = function VeDmMWMetaNode( name, length, element ) { + // Parent constructor + ve.dm.LeafNode.call( this, name, 0, element ); +}; + +/* Inheritance */ + +ve.inheritClass( ve.dm.MWMetaNode, ve.dm.MetaNode ); + +/* Static Properties */ + +ve.dm.MWMetaNode.static.name = 'MWmeta'; + +ve.dm.MWMetaNode.static.matchRdfaTypes = [ /^mw:/ ]; + +// toDataElement inherited from MetaNode, will return regular metaBlock/metaInline elements but +// that's fine. This class is only here so that <meta>/<link> tags with an mw: type are correctly +// mapped to MetaNode and aren't alienated. + +/* Registration */ + +ve.dm.modelRegistry.register( ve.dm.MWMetaNode ); diff --git a/modules/ve/dm/nodes/ve.dm.MetaNode.js b/modules/ve/dm/nodes/ve.dm.MetaNode.js index f4edfbf..c45d1fa 100644 --- a/modules/ve/dm/nodes/ve.dm.MetaNode.js +++ b/modules/ve/dm/nodes/ve.dm.MetaNode.js @@ -16,7 +16,7 @@ * @param {number} [length] Length of content data in document; ignored and overridden to 0 * @param {Object} [element] Reference to element in linear model */ -ve.dm.MetaNode = function VeDmMetaBlockNode( name, length, element ) { +ve.dm.MetaNode = function VeDmMetaNode( name, length, element ) { // Parent constructor ve.dm.LeafNode.call( this, name, 0, element ); }; diff --git a/modules/ve/dm/ve.dm.Converter.js b/modules/ve/dm/ve.dm.Converter.js index cdc5c11..330e42a 100644 --- a/modules/ve/dm/ve.dm.Converter.js +++ b/modules/ve/dm/ve.dm.Converter.js @@ -260,14 +260,6 @@ case Node.ELEMENT_NODE: modelName = this.modelRegistry.matchElement( childDomElement ); modelClass = this.modelRegistry.lookup( modelName ) || ve.dm.AlienNode; - // HACK: force MetaNode for <meta>/<link> even if they have an mw: type - // FIXME EWWWWWW find a better way to handle this - if ( - ( childDomElement.nodeName.toLowerCase() === 'meta' || childDomElement.nodeName.toLowerCase() === 'link' ) && - ( modelClass.prototype instanceof ve.dm.AlienNode || modelClass === ve.dm.AlienNode ) - ) { - modelClass = ve.dm.MetaNode; - } if ( modelClass.prototype instanceof ve.dm.Annotation ) { annotation = this.annotationFactory.create( modelName, childDomElement ); diff --git a/modules/ve/test/index.php b/modules/ve/test/index.php index 9dbbe9e..92db8eb 100644 --- a/modules/ve/test/index.php +++ b/modules/ve/test/index.php @@ -80,6 +80,7 @@ <script src="../../ve/dm/nodes/ve.dm.ListNode.js"></script> <script src="../../ve/dm/nodes/ve.dm.MetaNode.js"></script> <script src="../../ve/dm/nodes/ve.dm.MWEntityNode.js"></script> + <script src="../../ve/dm/nodes/ve.dm.MWMetaNode.js"></script> <script src="../../ve/dm/nodes/ve.dm.ParagraphNode.js"></script> <script src="../../ve/dm/nodes/ve.dm.PreformattedNode.js"></script> <script src="../../ve/dm/nodes/ve.dm.TableCellNode.js"></script> -- To view, visit https://gerrit.wikimedia.org/r/50027 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4c69bff4981eef78415b43d31c3fd2ee271450ef Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Catrope <roan.katt...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits