From a1a448b6deb6ac6c20ec7fb057726616a0b5ef41 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Tue, 15 Oct 2013 18:37:03 +0100 Subject: [PATCH] Rename storeDomElements to storeGeneratedContents The default is to store the entire generated DOM node, but in general classes can store anything that can be held by the store. Change-Id: Ia761079fadfb5a6cfa2f00e5b5e23d6c6d3468ac --- .../ve-mw/dm/nodes/ve.dm.MWExtensionNode.js | 2 +- .../dm/nodes/ve.dm.MWTransclusionNode.js | 2 +- .../ve/ce/nodes/ve.ce.GeneratedContentNode.js | 23 ++++++++++--------- .../ve/dm/nodes/ve.dm.GeneratedContentNode.js | 6 ++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js index 8f40a394ec..fff9e4fc2c 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js @@ -64,7 +64,7 @@ ve.dm.MWExtensionNode.static.toDataElement = function ( domElements, converter ) } }; - index = this.storeDomElements( dataElement, domElements, converter.getStore() ); + index = this.storeGeneratedContents( dataElement, domElements, converter.getStore() ); dataElement.attributes.originalIndex = index; return dataElement; diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js index a55fa6f506..c68c65788e 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js @@ -80,7 +80,7 @@ ve.dm.MWTransclusionNode.static.toDataElement = function ( domElements, converte } }; - index = this.storeDomElements( dataElement, domElements, converter.getStore() ); + index = this.storeGeneratedContents( dataElement, domElements, converter.getStore() ); dataElement.attributes.originalIndex = index; return dataElement; diff --git a/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js b/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js index 5d997d6a5d..dd0d7c820b 100644 --- a/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js +++ b/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js @@ -87,23 +87,23 @@ ve.ce.GeneratedContentNode.prototype.onGeneratedContentNodeUpdate = function () /** * Rerender the contents of this node. * - * @param {HTMLElement[]} domElements Array of DOM elements + * @param {Object|string|Array} generatedContents Generated contents, in the default case an HTMLElement array * @emits setup * @emits teardown */ -ve.ce.GeneratedContentNode.prototype.render = function ( domElements ) { +ve.ce.GeneratedContentNode.prototype.render = function ( generatedContents ) { var $rendering, doc = this.getElementDocument(); if ( this.live ) { this.emit( 'teardown' ); } // Filter out link, meta and style tags for bug 50043 - $rendering = $( ve.copyDomElements( domElements, doc ) ).not( 'link, meta, style' ); + $rendering = $( ve.copyDomElements( generatedContents, doc ) ).not( 'link, meta, style' ); // Also remove link, meta and style tags nested inside other tags $rendering.find( 'link, meta, style' ).remove(); this.$.empty().append( $rendering ); if ( this.live ) { this.emit( 'setup' ); - this.afterRender( domElements ); + this.afterRender( generatedContents ); } }; @@ -112,7 +112,7 @@ ve.ce.GeneratedContentNode.prototype.render = function ( domElements ) { * * Nodes may override this method if the rerender event needs to be deferred (e.g. until images have loaded) * - * @param {HTMLElement[]} domElements Array of DOM elements + * @param {Object|string|Array} generatedContents Generated contents * @emits rerender */ ve.ce.GeneratedContentNode.prototype.afterRender = function () { @@ -160,9 +160,9 @@ ve.ce.GeneratedContentNode.prototype.forceUpdate = function ( config ) { promise = this.generatingPromise = this.generateContents( config ); promise // If this promise is no longer the currently pending one, ignore it completely - .done( function ( domElements ) { + .done( function ( generatedContents ) { if ( node.generatingPromise === promise ) { - node.doneGenerating( domElements, config ); + node.doneGenerating( generatedContents, config ); } } ) .fail( function () { @@ -189,16 +189,17 @@ ve.ce.GeneratedContentNode.prototype.startGenerating = function () { * Called when the node successfully finishes generating new content. * * @method - * @param {HTMLElement[]} domElements Generated content + * @param {Object|string|Array} generatedContents Generated contents * @param {Object} [config] Config object passed to forceUpdate() */ -ve.ce.GeneratedContentNode.prototype.doneGenerating = function ( domElements, config ) { +ve.ce.GeneratedContentNode.prototype.doneGenerating = function ( generatedContents, config ) { var store = this.model.doc.getStore(), hash = ve.getHash( [ this.model, config ] ); - store.index( domElements, hash ); + + store.index( generatedContents, hash ); this.$.removeClass( 've-ce-generatedContentNode-generating' ); this.generatingPromise = null; - this.render( domElements ); + this.render( generatedContents ); }; /** diff --git a/modules/ve/dm/nodes/ve.dm.GeneratedContentNode.js b/modules/ve/dm/nodes/ve.dm.GeneratedContentNode.js index e64ae20a27..79c32047a4 100644 --- a/modules/ve/dm/nodes/ve.dm.GeneratedContentNode.js +++ b/modules/ve/dm/nodes/ve.dm.GeneratedContentNode.js @@ -24,11 +24,11 @@ ve.dm.GeneratedContentNode.static = {}; /** * Store HTML of DOM elements, hashed on data element * @param {Object} dataElement Data element - * @param {HTMLElement[]} domElements DOM elements + * @param {Object|string|Array} generatedContents Generated contents * @param {ve.dm.IndexValueStore} store Index-value store * @returns {number} Index of stored data */ -ve.dm.GeneratedContentNode.static.storeDomElements = function ( dataElement, domElements, store ) { +ve.dm.GeneratedContentNode.static.storeGeneratedContents = function ( dataElement, generatedContents, store ) { var hash = ve.getHash( [ this.getHashObject( dataElement ), undefined ] ); - return store.index( domElements, hash ); + return store.index( generatedContents, hash ); }; \ No newline at end of file