From 5838f051165745c08ec1f3341c0e5c36151e636f Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Fri, 8 Mar 2013 10:51:44 -0500 Subject: [PATCH] Merge tags without a space, fixes #941 --- js/id/core/entity.js | 14 ++++++++------ test/spec/actions/join.js | 2 +- test/spec/core/entity.js | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/js/id/core/entity.js b/js/id/core/entity.js index bd402552e..8ea60bb31 100644 --- a/js/id/core/entity.js +++ b/js/id/core/entity.js @@ -3,7 +3,9 @@ iD.Entity = function(attrs) { if (this instanceof iD.Entity) return; // Create the appropriate subtype. - if (attrs && attrs.type) return iD.Entity[attrs.type].apply(this, arguments); + if (attrs && attrs.type) { + return iD.Entity[attrs.type].apply(this, arguments); + } // Initialize a generic Entity (used only in tests). return (new iD.Entity()).initialize(arguments); @@ -71,7 +73,7 @@ iD.Entity.prototype = { var t1 = merged[k], t2 = tags[k]; if (t1 && t1 !== t2) { - merged[k] = t1 + "; " + t2; + merged[k] = t1 + ';' + t2; } else { merged[k] = t2; } @@ -85,9 +87,9 @@ iD.Entity.prototype = { hasInterestingTags: function() { return _.keys(this.tags).some(function(key) { - return key != "attribution" && - key != "created_by" && - key != "source" && + return key != 'attribution' && + key != 'created_by' && + key != 'source' && key != 'odbl' && key.indexOf('tiger:') !== 0; }); @@ -114,7 +116,7 @@ iD.Entity.prototype = { // Generate a string such as 'river' or 'Fred's House' for an entity. if (!this.tags || !Object.keys(this.tags).length) { return ''; } - var mainkeys = ['highway','amenity','railway','waterway','natural'], + var mainkeys = ['highway', 'amenity', 'railway', 'waterway', 'natural'], n = []; if (this.tags.name) n.push(this.tags.name); diff --git a/test/spec/actions/join.js b/test/spec/actions/join.js index 6951013d3..59589ded3 100644 --- a/test/spec/actions/join.js +++ b/test/spec/actions/join.js @@ -152,7 +152,7 @@ describe("iD.actions.Join", function () { graph = iD.actions.Join(['-', '='])(graph); - expect(graph.entity('-').tags).to.eql({a: 'a', b: '-; =', c: 'c', d: 'd'}); + expect(graph.entity('-').tags).to.eql({a: 'a', b: '-;=', c: 'c', d: 'd'}); }); it("merges relations", function () { diff --git a/test/spec/core/entity.js b/test/spec/core/entity.js index f0b7e0b19..51a89dee4 100644 --- a/test/spec/core/entity.js +++ b/test/spec/core/entity.js @@ -86,7 +86,7 @@ describe('iD.Entity', function () { it("combines conflicting tags with semicolons", function () { var a = iD.Entity({tags: {a: 'a'}}), b = a.mergeTags({a: 'b'}); - expect(b.tags).to.eql({a: 'a; b'}); + expect(b.tags).to.eql({a: 'a;b'}); }); });