mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
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:
parent
2566110456
commit
50de745afd
|
@ -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 ];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue