Skip to content

Commit

Permalink
fix: don't strip root pseudo-class
Browse files Browse the repository at this point in the history
  • Loading branch information
asgerb committed Feb 6, 2024
1 parent cea4110 commit ae77e8a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/roadie/selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def ==(other)
:before :after
:enabled :disabled :checked
:host
:root
].freeze

def pseudo_element?
Expand Down
23 changes: 23 additions & 0 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
<html>
<head>
<title>Hello world!</title>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
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
<html>
Expand Down

0 comments on commit ae77e8a

Please sign in to comment.