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
This commit is contained in:
Ed Sanders 2013-12-13 16:48:23 +00:00
parent 89ae1aa107
commit 2843714834
2 changed files with 6 additions and 4 deletions

View file

@ -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

View file

@ -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 );