mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
ve.dm.MWTemplateModel: Never remove empty required parameters
Follow-up to d127dc48b7
.
Bug: T276989
Change-Id: I042b2ce180e3af4ae6899cb7d8c7ed8246f25cb6
This commit is contained in:
parent
155a591820
commit
989792ac7f
|
@ -339,6 +339,7 @@ ve.dm.MWTemplateModel.prototype.serialize = function () {
|
|||
origData = this.originalData || {},
|
||||
origParams = origData.params || {},
|
||||
template = { target: this.getTarget(), params: {} },
|
||||
spec = this.getSpec(),
|
||||
params = this.getParameters();
|
||||
|
||||
for ( name in params ) {
|
||||
|
@ -346,8 +347,14 @@ ve.dm.MWTemplateModel.prototype.serialize = function () {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Don't add empty parameters if they were not present before the edit (T101075)
|
||||
if ( params[ name ].getValue() === '' && !Object.prototype.hasOwnProperty.call( origParams, name ) ) {
|
||||
if (
|
||||
// Don't add empty parameters (T101075)
|
||||
params[ name ].getValue() === '' &&
|
||||
// …unless they were present before the edit
|
||||
!Object.prototype.hasOwnProperty.call( origParams, name ) &&
|
||||
// …unless they are required (T276989)
|
||||
!( spec.isParameterKnown( name ) && spec.isParameterRequired( name ) )
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue