Merge branch 'bhousel-bhousel-fields'

This commit is contained in:
John Firebaugh
2014-05-18 12:39:24 -07:00

View File

@@ -162,10 +162,22 @@ iD.ui.RawTagEditor = function(context) {
}
function keyChange(d) {
var tag = {};
tag[d.key] = undefined;
tag[this.value] = d.value;
d.key = this.value; // Maintain DOM identity through the subsequent update.
var kOld = d.key,
kNew = this.value.trim(),
tag = {};
if (kNew && kNew !== kOld) {
var match = kNew.match(/^(.*?)(?:_(\d+))?$/),
base = match[1],
suffix = +(match[2] || 1);
while (tags[kNew]) { // rename key if already in use
kNew = base + '_' + suffix++;
}
}
tag[kOld] = undefined;
tag[kNew] = d.value;
d.key = kNew; // Maintain DOM identity through the subsequent update.
this.value = kNew;
event.change(tag);
}