Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #136 from TooTallNate/add/prefix-selectors-root-su…

…pport

prefix-selectors: add support for :root pseudo-class
  • Loading branch information...
commit ae58502ef4e6462e4080baff8b7bdf76a83c6093 2 parents 33e2c11 + 6b62f2f
@jonathanong jonathanong authored
View
4 lib/plugins/prefix-selectors.js
@@ -19,9 +19,11 @@ module.exports = function(str) {
style.rules = style.rules.map(function(rule){
if (!rule.selectors) return rule;
rule.selectors = rule.selectors.map(function(selector){
+ if (':root' == selector) return str;
+ selector = selector.replace(/^\:root\s?/, '');
return str + ' ' + selector;
});
return rule;
});
}
-};
+};
View
11 test/fixtures/prefix-selectors-root.css
@@ -0,0 +1,11 @@
+:root {
+ bar: 'baz';
+}
+
+:root foo {
+ color: #f00;
+}
+
+bar {
+ font-family: "Wingdings";
+}
View
11 test/fixtures/prefix-selectors-root.out.css
@@ -0,0 +1,11 @@
+#dialog {
+ bar: 'baz';
+}
+
+#dialog foo {
+ color: #f00;
+}
+
+#dialog bar {
+ font-family: "Wingdings";
+}
View
6 test/rework.js
@@ -219,6 +219,12 @@ describe('rework', function(){
.toString()
.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(){
Please sign in to comment.
Something went wrong with that request. Please try again.