Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1x 1x 1x 1x 1x 1x 1x | /*! * VisualEditor DataModel GeneratedContentNode class. * * @copyright See AUTHORS.txt */ /** * DataModel generated content node. * * @class * @abstract * * @constructor */ ve.dm.GeneratedContentNode = function VeDmGeneratedContentNode() { }; /* Inheritance */ OO.initClass( ve.dm.GeneratedContentNode ); /* Events */ /** * @event ve.dm.GeneratedContentNode#generatedContentsError * @param {jQuery} $element Element containing the error message */ /* Static methods */ /** * Store HTML of DOM elements, hashed on data element * * @static * @param {ve.dm.LinearData.Element} dataElement Data element * @param {Object|string|Array} generatedContents Generated contents * @param {ve.dm.HashValueStore} store Hash-value store * @param {Object} [config] Additional data * @return {string} Hash of stored data */ ve.dm.GeneratedContentNode.static.storeGeneratedContents = function ( dataElement, generatedContents, store, config ) { const hash = OO.getHash( [ this.getHashObjectForRendering( dataElement ), config ] ); return store.hash( generatedContents, hash ); }; /** * Fetch generated contents from store * * @static * @param {ve.dm.LinearData.Element} dataElement Data element * @param {ve.dm.HashValueStore} store Hash-value store * @param {Object} [config] Additional data * @return {Object|string|Array} Generated contents, or null if not found */ ve.dm.GeneratedContentNode.static.fetchGeneratedContents = function ( dataElement, store, config ) { const hash = OO.getHash( [ this.getHashObjectForRendering( dataElement ), config ] ); return store.value( store.hashOfValue( null, hash ) ); }; /** * Get as hash object that uniquely describes the rendering * * Sub-classes can simplify this hash if certain attributes * don't affect the rendering. * * @static * @param {ve.dm.LinearData.Element} dataElement Data element * @return {Object} Hash object */ ve.dm.GeneratedContentNode.static.getHashObjectForRendering = function ( dataElement ) { return this.getHashObject( dataElement ); }; /* Methods */ /** * Get as hash object that uniquely describes the rendering * * The actual logic is in a static function as this needs * to be accessible from ve.dm.Converter * * @return {Object} Hash object */ ve.dm.GeneratedContentNode.prototype.getHashObjectForRendering = function () { return this.constructor.static.getHashObjectForRendering( this.element ); }; /** * Fetch generated contents from store * * @param {Object} [config] Additional data * @return {Object|string|Array} Generated contents, or null if not found */ ve.dm.GeneratedContentNode.prototype.fetchGeneratedContents = function ( config ) { return this.doc ? this.constructor.static.fetchGeneratedContents( this.element, this.doc.getStore(), config ) : null; }; |