From 40810dab04051185acea79e209a0c69b915818c3 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 23 May 2014 15:06:10 -0400 Subject: [PATCH] Correctly trim whitespace in semicolon-separated multivalues #2236 --- js/id/ui/entity_editor.js | 4 +++- js/id/ui/preset/combo.js | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/js/id/ui/entity_editor.js b/js/id/ui/entity_editor.js index 4f59f209e..24fecc682 100644 --- a/js/id/ui/entity_editor.js +++ b/js/id/ui/entity_editor.js @@ -133,11 +133,13 @@ iD.ui.EntityEditor = function(context) { function clean(o) { var out = {}, k, v; + /*jshint -W083 */ for (k in o) { if (k && (v = o[k]) !== undefined) { - out[k] = v.trim(); + out[k] = v.split(';').map(function(s) { return s.trim(); }).join(';'); } } + /*jshint +W083 */ return out; } diff --git a/js/id/ui/preset/combo.js b/js/id/ui/preset/combo.js index 18f4a38af..3d2149bf2 100644 --- a/js/id/ui/preset/combo.js +++ b/js/id/ui/preset/combo.js @@ -44,7 +44,12 @@ iD.ui.preset.typeCombo = function(field) { } function change() { - var value = input.value().replace(/\s+/g, '_'); + var value = input.value() + .split(';') + .map(function(s) { return s.trim(); }) + .join(';') + .replace(/\s+/g, '_'); + if (field.type === 'typeCombo' && !value) value = 'yes'; var t = {};