mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 01:33:03 +00:00
Merge branch 'bhousel-bhousel-fields'
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user