Fix copyDomElement issues

* Fix bug in MWTransclusionNode sometimes passing a NodeList rather
  than an array (caused an error because NodeLists can't be .map()ped)
* Use copyDomElements in ce.AlienNode as well

Change-Id: I11c6483d3c062047be80f75a3fac03f13bff9662
This commit is contained in:
Roan Kattouw 2013-06-18 16:18:51 -07:00 committed by Krinkle
parent 60da007ab9
commit dfbd870e16
2 changed files with 3 additions and 2 deletions

View file

@ -54,7 +54,8 @@ ve.ce.AlienNode.static.$phantomTemplate = ve.ce.AlienNode.static.$phantomTemplat
* @method
*/
ve.ce.AlienNode.prototype.onUpdate = function () {
this.$.html( ve.copyArray( this.model.getAttribute( 'domElements' ) || [] ) );
// TODO use GeneratedContentNode the way it was meant to be used
this.$.html( ve.copyDomElements( this.model.getAttribute( 'domElements' ) || [], this.getElementDocument() ) );
};
/* Concrete subclasses */

View file

@ -85,7 +85,7 @@ ve.ce.MWTransclusionNode.prototype.onParseSuccess = function ( deferred, respons
// We have to do this because the PHP parser wraps everything in <p>s, and inline templates
// will render strangely when wrapped in <p>s.
if ( contentNodes.length === 1 && contentNodes[0].nodeName.toLowerCase() === 'p' ) {
contentNodes = contentNodes[0].childNodes;
contentNodes = Array.prototype.slice.apply( contentNodes[0].childNodes );
}
deferred.resolve( contentNodes );
};