Skip to content

Commit

Permalink
Merge pull request #136 from TooTallNate/add/prefix-selectors-root-su…
Browse files Browse the repository at this point in the history
…pport

prefix-selectors: add support for :root pseudo-class
  • Loading branch information
jonathanong committed Jan 2, 2014
2 parents 33e2c11 + 6b62f2f commit ae58502
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/plugins/prefix-selectors.js
Expand Up @@ -19,9 +19,11 @@ module.exports = function(str) {
style.rules = style.rules.map(function(rule){ style.rules = style.rules.map(function(rule){
if (!rule.selectors) return rule; if (!rule.selectors) return rule;
rule.selectors = rule.selectors.map(function(selector){ rule.selectors = rule.selectors.map(function(selector){
if (':root' == selector) return str;
selector = selector.replace(/^\:root\s?/, '');
return str + ' ' + selector; return str + ' ' + selector;
}); });
return rule; return rule;
}); });
} }
}; };
11 changes: 11 additions & 0 deletions test/fixtures/prefix-selectors-root.css
@@ -0,0 +1,11 @@
:root {
bar: 'baz';
}

:root foo {
color: #f00;
}

bar {
font-family: "Wingdings";
}
11 changes: 11 additions & 0 deletions test/fixtures/prefix-selectors-root.out.css
@@ -0,0 +1,11 @@
#dialog {
bar: 'baz';
}

#dialog foo {
color: #f00;
}

#dialog bar {
font-family: "Wingdings";
}
6 changes: 6 additions & 0 deletions test/rework.js
Expand Up @@ -219,6 +219,12 @@ describe('rework', function(){
.toString() .toString()
.should.equal(fixture('prefix-selectors.out')); .should.equal(fixture('prefix-selectors.out'));
}) })
it('should use the prefix as the :root pseudo-class', function(){
rework(fixture('prefix-selectors-root'))
.use(rework.prefixSelectors('#dialog'))
.toString()
.should.equal(fixture('prefix-selectors-root.out'));
})
}) })


describe('.url(fn)', function(){ describe('.url(fn)', function(){
Expand Down

0 comments on commit ae58502

Please sign in to comment.