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
This commit is contained in:
Catrope 2013-06-05 17:49:22 -07:00
parent 3aae3e80bd
commit 4ce69758cc

View file

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