Merge tags without a space, fixes #941

This commit is contained in:
Tom MacWright
2013-03-08 10:51:44 -05:00
parent 9d80f60a7f
commit 5838f05116
3 changed files with 10 additions and 8 deletions
+8 -6
View File
@@ -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);
+1 -1
View File
@@ -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 () {
+1 -1
View File
@@ -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'});
});
});