MWExtensionNode: Copy mw data before modifying

Otherwise we are directly modifying model.element.attributes
which is very bad.

Change-Id: Icf066a5848b9c67c2c4b3fcafd72d0142996e48d
This commit is contained in:
Ed Sanders 2015-10-01 13:32:38 +01:00
parent 2566110456
commit 50de745afd

View file

@ -52,15 +52,15 @@ ve.ce.MWExtensionNode.static.rendersEmpty = false;
ve.ce.MWExtensionNode.prototype.generateContents = function ( config ) {
var xhr, attr, wikitext,
deferred = $.Deferred(),
mwData = this.getModel().getAttribute( 'mw' ),
mwData = ve.copy( this.getModel().getAttribute( 'mw' ) ),
extsrc = config && config.extsrc !== undefined ? config.extsrc : mwData.body.extsrc,
attrs = config && config.attrs || mwData.attrs,
tagName = this.getModel().getExtensionName();
// undefined means omit the attribute, not convert it to string 'undefined'
for ( attr in mwData.attrs ) {
if ( mwData.attrs[ attr ] === undefined ) {
delete mwData.attrs[ attr ];
for ( attr in attrs ) {
if ( attrs[ attr ] === undefined ) {
delete attrs[ attr ];
}
}