From 284371483419ec428979ac21199a63fa798c6fa3 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 13 Dec 2013 16:48:23 +0000 Subject: [PATCH] Fix hashes in MW toDomElement functions Hashes weren't using the new [ object, config ] set up so were never matching the store. Also added a check to see if the originalDomElements actually exists before trying to use them (they may have been removed by a clone operation). Change-Id: I886e369ced9a9d2e0e457ced9c21b2a7a8e55d58 --- modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js | 2 +- modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js index 8f568da693..fff60a76b2 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js @@ -74,7 +74,7 @@ ve.dm.MWExtensionNode.static.toDataElement = function ( domElements, converter ) ve.dm.MWExtensionNode.static.toDomElements = function ( dataElement, doc, converter ) { var el, - index = converter.getStore().indexOfHash( OO.getHash( this.getHashObject( dataElement ) ) ), + index = converter.getStore().indexOfHash( OO.getHash( [ this.getHashObject( dataElement ), undefined ] ) ), originalMw = dataElement.attributes.originalMw; // If the transclusion is unchanged just send back the diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js index 1407c15676..875642eff3 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js @@ -90,14 +90,16 @@ ve.dm.MWTransclusionNode.static.toDataElement = function ( domElements, converte ve.dm.MWTransclusionNode.static.toDomElements = function ( dataElement, doc, converter ) { var el, - index = converter.getStore().indexOfHash( OO.getHash( this.getHashObject( dataElement ) ) ), + index = converter.getStore().indexOfHash( OO.getHash( [ this.getHashObject( dataElement ), undefined ] ) ), originalMw = dataElement.attributes.originalMw; // If the transclusion is unchanged just send back the // original DOM elements so selser can skip over it if ( - index === dataElement.attributes.originalIndex || - ( originalMw && ve.compare( dataElement.attributes.mw, JSON.parse( originalMw ) ) ) + dataElement.attributes.originalDomElements && ( + index === dataElement.attributes.originalIndex || + ( originalMw && ve.compare( dataElement.attributes.mw, JSON.parse( originalMw ) ) ) + ) ) { // The object in the store is also used for CE rendering so return a copy return ve.copyDomElements( dataElement.attributes.originalDomElements, doc );