From 25a2940ebc7950764cbb174bc48b685a385d6498 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 6 Dec 2012 12:48:09 -0500 Subject: [PATCH] Fix regex nesting inheritance --- lib/carto/tree/filterset.js | 3 +++ test/rendering/regex_nest.mml | 14 ++++++++++++++ test/rendering/regex_nest.mss | 6 ++++++ test/rendering/regex_nest.result | 21 +++++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 test/rendering/regex_nest.mml create mode 100644 test/rendering/regex_nest.mss create mode 100644 test/rendering/regex_nest.result diff --git a/lib/carto/tree/filterset.js b/lib/carto/tree/filterset.js index ad73938..10d9383 100644 --- a/lib/carto/tree/filterset.js +++ b/lib/carto/tree/filterset.js @@ -97,6 +97,9 @@ Object.defineProperty(tree.Filterset.prototype, 'addable', { if (key + '<=' in this && this[key + '<='].val < value) return false; return true; + case '=~': + return true; + case '!=': if (key + '=' in this) return (this[key + '='].val == value) ? false : null; if (key + '!=' + value in this) return null; diff --git a/test/rendering/regex_nest.mml b/test/rendering/regex_nest.mml new file mode 100644 index 0000000..82eebac --- /dev/null +++ b/test/rendering/regex_nest.mml @@ -0,0 +1,14 @@ +{ + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", + "Stylesheet": [ + "regex_nest.mss" + ], + "Layer": [{ + "name": "railway", + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", + "Datasource": { + "file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip", + "type": "shape" + } + }] +} diff --git a/test/rendering/regex_nest.mss b/test/rendering/regex_nest.mss new file mode 100644 index 0000000..21844ba --- /dev/null +++ b/test/rendering/regex_nest.mss @@ -0,0 +1,6 @@ +#railway[foo='bar'] { + [name =~ "East.*"] { + line-color: green; + line-width: 4; + } +} diff --git a/test/rendering/regex_nest.result b/test/rendering/regex_nest.result new file mode 100644 index 0000000..e6f372f --- /dev/null +++ b/test/rendering/regex_nest.result @@ -0,0 +1,21 @@ + + + + + + + + railway + + + + + + +