From bdf1832cbc2f9e0dc7355bb7d435a9f6ab574d7e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 29 Mar 2013 23:07:12 +0000 Subject: Allow fresh elements to be specified --- lib/style-reader.js | 6 +++++- tests/style-reader.tests.js | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/style-reader.js b/lib/style-reader.js index ca4e18a..7ee36c2 100644 --- a/lib/style-reader.js +++ b/lib/style-reader.js @@ -10,12 +10,16 @@ function read(string) { } function readElement(string) { - var parts = string.split("."); + var colonParts = string.split(":"); + var parts = colonParts[0].split("."); var tagName = parts[0]; var classNames = parts.slice(1); var options = {}; if (classNames.length > 0) { options["class"] = classNames.join(" "); } + if (colonParts[1] === "fresh") { + options.fresh = true; + } return styles.element(tagName, options); } diff --git a/tests/style-reader.tests.js b/tests/style-reader.tests.js index 10047dc..11e5364 100644 --- a/tests/style-reader.tests.js +++ b/tests/style-reader.tests.js @@ -26,4 +26,11 @@ describe('styleReader.read', function() { ]) assert.deepEqual(styleReader.read("p.tip.help"), expected); }); + + test('reads when element must be fresh', function() { + var expected = styles.elements([ + styles.element("p", {"fresh": true}) + ]) + assert.deepEqual(styleReader.read("p:fresh"), expected); + }); }) -- cgit v1.2.3