From 132e699c899da98e29ef68dbb6109b67950b76d3 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 27 Sep 2016 23:20:16 -0400 Subject: [PATCH] Replace extend with smarter copy for tag changes Because compound fields like `address` may send a bunch of undefined tag values in the `changed` object, and we don't want them all to turn into raw tags (but we do want them to override any existing tags). This is subtlely different than what `_.extend({}, existing, changed)` did. --- modules/ui/entity_editor.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/ui/entity_editor.js b/modules/ui/entity_editor.js index 5faac400e..af10a0862 100644 --- a/modules/ui/entity_editor.js +++ b/modules/ui/entity_editor.js @@ -208,11 +208,18 @@ export function EntityEditor(context) { function changeTags(changed, onInput) { var entity = context.entity(id), annotation = t('operations.change_tags.annotation'), - tags = _.extend({}, entity.tags, changed); + tags = _.clone(entity.tags); + + _.forEach(changed, function(v, k) { + if (v !== undefined || tags.hasOwnProperty(k)) { + tags[k] = v; + } + }); if (!onInput) { tags = clean(tags); } + if (!_.isEqual(entity.tags, tags)) { if (coalesceChanges) { context.overwrite(ChangeTags(id, tags), annotation);