Skip to content

Commit

Permalink
Add @container CSS at-rule to the relaxed config
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrove committed Dec 30, 2024
1 parent 010e4e2 commit 45dbeac
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Sanitize itself has no breaking API changes in this release, but the major versi

- Added over 100 new CSS properties to the relaxed config, representing all properties that are listed with a status of "Working Draft" or better in the latest [W3C "All Properties" list](https://www.w3.org/Style/CSS/all-properties.en.html).

- Added the `@container` CSS at-rule to the relaxed config.

- Added the `-webkit-text-fill-color` CSS property to the relaxed config. [@radar - #244](https://github.com/rgrove/sanitize/pull/244)

### Changed
Expand Down
1 change: 1 addition & 0 deletions lib/sanitize/config/relaxed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module Config
-moz-keyframes
-o-keyframes
-webkit-keyframes
container
document
keyframes
media
Expand Down
35 changes: 35 additions & 0 deletions test/test_sanitize_css.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,41 @@
).strip
end

it "preserves allowlisted @container at-rules" do
# Sample code courtesy of MDN:
# https://developer.mozilla.org/en-US/docs/Web/CSS/@container
css = %(
@container (width > 400px) {
h2 {
font-size: 1.5em;
}
}
/* with an optional <container-name> */
@container tall (height > 30rem) {
h2 {
line-height: 1.6;
}
}
/* multiple queries in a single condition */
@container (width > 400px) and style(--responsive: true) {
h2 {
font-size: 1.5em;
}
}
/* condition list */
@container card (width > 400px), style(--responsive: true) {
h2 {
font-size: 1.5em;
}
}
).strip

_(@relaxed.stylesheet(css).strip).must_equal css
end

describe "when blockless at-rules are allowlisted" do
before do
@scss = Sanitize::CSS.new(Sanitize::Config.merge(Sanitize::Config::RELAXED[:css], {
Expand Down

0 comments on commit 45dbeac

Please sign in to comment.