mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user