From 4ce69758ccee2497f91823d1246b03a36d5b8e26 Mon Sep 17 00:00:00 2001 From: Catrope Date: Wed, 5 Jun 2013 17:49:22 -0700 Subject: [PATCH] Fix freaky disappearance of template nodes ce.GeneratedContentNode had an interesting bug where it called .append() directly on DOM elements stored in the store. They weren't cloned, which meant the previous rendering of the same node would just disappear, and they also weren't adopted into the correct document which would probably have caused other issues as well. Properly clone and transplant the nodes from the store before attaching them to the DOM. Change-Id: I423db85cb7c3851a9bf68de03c72aa22994d9474 --- modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js b/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js index 4253fcb7f8..68702c5501 100644 --- a/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js +++ b/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js @@ -33,13 +33,18 @@ ve.ce.GeneratedContentNode = function VeCeGeneratedContentNode() { * @method */ ve.ce.GeneratedContentNode.prototype.onUpdate = function () { - var store = this.model.doc.getStore(), + var doc = this.getElementDocument(), + store = this.model.doc.getStore(), index = store.indexOfHash( ve.getHash( this.model ) ); if ( index !== null ) { if ( this.live ) { this.emit( 'teardown' ); } - this.$.empty().append( store.value( index ) ); + this.$.empty().append( + this.$$( store.value( index ) ).map( function ( i, domElement ) { + return doc.importNode( domElement, true ); + } ) + ); if ( this.live ) { this.emit( 'setup' ); }