diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-01-25 15:37:14 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-01-25 15:37:14 +0000 |
| commit | 208318fd35c1f3107dc189e0c17330924fd74600 (patch) | |
| tree | fed47d3f32359caec2530fb480cfd4a833fcfc01 | |
| parent | b79eaad70e41ea4843beced7c5e575d105362e10 (diff) | |
Allow HTML paths with no elements
| -rw-r--r-- | lib/style-reader.js | 8 | ||||
| -rw-r--r-- | tests/style-reader.tests.js | 10 |
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/style-reader.js b/lib/style-reader.js index b76478f..ef379b6 100644 --- a/lib/style-reader.js +++ b/lib/style-reader.js @@ -19,12 +19,14 @@ function createStyleRule() { lop.rules.sequence.capture(documentMatcherRule()), lop.rules.tokenOfType("whitespace"), lop.rules.tokenOfType("arrow"), - lop.rules.tokenOfType("whitespace"), - lop.rules.sequence.capture(htmlPathRule()) + lop.rules.sequence.capture(lop.rules.optional(lop.rules.sequence( + lop.rules.tokenOfType("whitespace"), + lop.rules.sequence.capture(htmlPathRule()) + ).head())) ).map(function(documentMatcher, htmlPath) { return { from: documentMatcher, - to: htmlPath + to: htmlPath.valueOrElse(htmlPaths.empty) }; }); } diff --git a/tests/style-reader.tests.js b/tests/style-reader.tests.js index df32839..7927153 100644 --- a/tests/style-reader.tests.js +++ b/tests/style-reader.tests.js @@ -105,4 +105,14 @@ describe("styleReader.read", function() { } ); }); + + test("reads style mapping with no HTML path", function() { + assert.deepEqual( + readStyle("r =>"), + { + from: documentMatchers.run(), + to: htmlPaths.empty + } + ); + }); }); |
