diff --git a/Changelog.md b/Changelog.md index 4e126ce..ca7e0c4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,8 @@ [full changelog](https://github.com/Mange/roadie/compare/v5.2.0...master) +* Don't strip the [`:root` pseudo-class](https://developer.mozilla.org/en-US/docs/Web/CSS/:root) - [Asger Behncke Jacobsen](https://github.com/asgerb) (#173) + ### 5.2.0 [full changelog](https://github.com/Mange/roadie/compare/v5.1.0...v5.2.0) diff --git a/lib/roadie/selector.rb b/lib/roadie/selector.rb index 895a98e..7503f20 100644 --- a/lib/roadie/selector.rb +++ b/lib/roadie/selector.rb @@ -71,6 +71,7 @@ def ==(other) :before :after :enabled :disabled :checked :host + :root ].freeze def pseudo_element? diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index f2f583f..fc458fe 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -67,6 +67,29 @@ def parse_html(html) expect(styles).to include Roadie::Stylesheet.new("", css).to_s end + it "does not strip :root pseudo-class" do + document = Roadie::Document.new <<-HTML + + + Hello world! + + +

Hello world!

+ + + HTML + css = <<-CSS + :root { --color: red; } + CSS + document.add_css css + + result = parse_html document.transform + expect(result).to have_selector("html > head > style") + + styles = result.at_css("html > head > style").text + expect(styles).to include Roadie::Stylesheet.new("", css).to_s + end + it "can be configured to skip styles that cannot be inlined" do document = Roadie::Document.new <<-HTML