ve.dm.MWTemplateModel: Never remove empty required parameters

Follow-up to d127dc48b7.

Bug: T276989
Change-Id: I042b2ce180e3af4ae6899cb7d8c7ed8246f25cb6
This commit is contained in:
Bartosz Dziewoński 2021-03-12 22:50:42 +01:00
parent 155a591820
commit 989792ac7f

View file

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