Clone template dom elements being sent to converter

The dom elements in the IV store are used for rendering, so if they
are sent by reference to the converter they get re-attached, causing
all templates to disappear from the page whenever you press 'review
and save'.

Fix is to run it through ve.copyArray, which clones all the nodes.

Change-Id: I1b03351a28ac82e0fdb7e94e761cf65d6548e501
This commit is contained in:
Ed Sanders 2013-05-09 13:42:44 +01:00
parent 9c37181788
commit 3495c6f747

View file

@ -70,7 +70,8 @@ ve.dm.MWTemplateNode.static.toDomElements = function ( dataElement, doc, convert
if ( ve.compareObjects( dataElement.attributes.mw, dataElement.attributes.mwOriginal ) ) {
// If the template is unchanged just send back the original dom elements so selser can skip over it
index = converter.getStore().indexOfHash( ve.getHash( this.getHashObject( dataElement ) ) );
return converter.getStore().value( index );
// The object in the store is also used for rendering so return a copy
return ve.copyArray( converter.getStore().value( index ) );
} else {
span = doc.createElement( 'span' );
// All we need to send back to Parsoid is the original template marker,