| 1 | /*! |
| 2 | * VisualEditor DataModel LeafNode class. |
| 3 | * |
| 4 | * @copyright See AUTHORS.txt |
| 5 | */ |
| 6 | |
| 7 | /** |
| 8 | * DataModel leaf node. |
| 9 | * |
| 10 | * Leaf nodes can not have any children. |
| 11 | * |
| 12 | * @abstract |
| 13 | * @extends ve.dm.Node |
| 14 | * @mixes ve.LeafNode |
| 15 | * |
| 16 | * @constructor |
| 17 | * @param {Object} [element] Reference to element in linear model |
| 18 | */ |
| 19 | ve.dm.LeafNode = function VeDmLeafNode() { |
| 20 | // Mixin constructor |
| 21 | ve.LeafNode.call( this ); |
| 22 | |
| 23 | // Parent constructor |
| 24 | ve.dm.LeafNode.super.apply( this, arguments ); |
| 25 | }; |
| 26 | |
| 27 | /* Inheritance */ |
| 28 | |
| 29 | OO.inheritClass( ve.dm.LeafNode, ve.dm.Node ); |
| 30 | |
| 31 | OO.mixinClass( ve.dm.LeafNode, ve.LeafNode ); |
| 32 | |
| 33 | /* Static properties */ |
| 34 | |
| 35 | ve.dm.LeafNode.static.childNodeTypes = []; |
| 36 | |
| 37 | ve.dm.LeafNode.static.isDiffedAsLeaf = true; |
| 38 | |
| 39 | /* Methods */ |
| 40 | |
| 41 | /** |
| 42 | * Get the annotations that apply to the node. |
| 43 | * |
| 44 | * Annotations are grabbed directly from the linear model, so they are updated live. If the linear |
| 45 | * model element doesn't have a .annotations property, an empty array is returned. |
| 46 | * |
| 47 | * @return {number[]} Annotation set indexes in the index-value store |
| 48 | */ |
| 49 | ve.dm.LeafNode.prototype.getAnnotations = function () { |
| 50 | return this.element.annotations || []; |
| 51 | }; |