Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't strip :root pseudo-class #173

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
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
Loading