mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-11-23 23:43:54 +00:00
Fix serialization adding empty autovalue when not needed
The autovalue field appears to be the only one with this edge-case. This is because all other fields are either multi-lingual and processed by the `….allowLanguages` code path above, or because of other special-case handling somewhere else. The idea is: * Non-empty values are always added. * When the property (in this case `"autovalue": "…"` existed before, it's kept, even if it's now empty. Bug: T295074 Change-Id: Ie4d9825b89edb4bbbbc4283dc48e9113e537869a
This commit is contained in:
parent
baaaa4209c
commit
2b2033c6ec
|
@ -1074,17 +1074,20 @@ Model.prototype.outputTemplateData = function () {
|
|||
default:
|
||||
// Check if there's a value in the model
|
||||
if ( this.params[ key ][ prop ] !== undefined ) {
|
||||
var compareOrig = original.params[ oldKey ] && original.params[ oldKey ][ prop ];
|
||||
if ( allProps[ prop ].allowLanguages ) {
|
||||
normalizedValue = this.propRemoveUnusedLanguages( this.params[ key ][ prop ] );
|
||||
// Check if this should be displayed with language object or directly as string
|
||||
var compareOrig = original.params[ oldKey ] ? original.params[ oldKey ][ prop ] : {};
|
||||
if ( this.isOutputInLanguageObject( compareOrig, normalizedValue ) ) {
|
||||
if ( this.isOutputInLanguageObject( compareOrig || {}, normalizedValue ) ) {
|
||||
result.params[ name ][ prop ] = normalizedValue;
|
||||
} else {
|
||||
// Store only one language as a string
|
||||
result.params[ name ][ prop ] = normalizedValue[ defaultLang ];
|
||||
}
|
||||
} else {
|
||||
} else if ( this.params[ key ][ prop ] ||
|
||||
// Add empty strings only if the property existed before (empty or not)
|
||||
compareOrig !== undefined
|
||||
) {
|
||||
// Set up the result
|
||||
result.params[ name ][ prop ] = this.params[ key ][ prop ];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue