From ed03f791fd18276dfa0387abe7b2e823d8298872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 2 Feb 2011 17:01:10 -0500 Subject: [PATCH] clone rules that are already attached to a definition --- lib/mess/tree/definition.js | 1 + lib/mess/tree/rule.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/mess/tree/definition.js b/lib/mess/tree/definition.js index 09c6973..a1a03e1 100644 --- a/lib/mess/tree/definition.js +++ b/lib/mess/tree/definition.js @@ -7,6 +7,7 @@ tree.Definition = function Definition(selector, rules) { this.rules = rules; this.ruleIndex = []; for (var i = 0; i < this.rules.length; i++) { + if ('zoom' in this.rules[i]) this.rules[i] = this.rules[i].clone(); this.rules[i].zoom = selector.zoom; this.ruleIndex.push(this.rules[i].updateID()); } diff --git a/lib/mess/tree/rule.js b/lib/mess/tree/rule.js index 4391283..5a19d9e 100644 --- a/lib/mess/tree/rule.js +++ b/lib/mess/tree/rule.js @@ -9,6 +9,17 @@ tree.Rule = function Rule(name, value, index, filename) { this.variable = (name.charAt(0) === '@'); }; +tree.Rule.prototype.clone = function() { + var clone = Object.create(tree.Rule.prototype); + clone.name = this.name + clone.value = this.value; + clone.index = this.index; + clone.symbolizer = this.symbolizer; + clone.filename = this.filename; + clone.variable = this.variable; + return clone; +}; + tree.Rule.prototype.updateID = function() { return this.id = this.zoom + '#' + this.name; };