Skip to content

Commit 45dbeac

Browse files
committed
Add @container CSS at-rule to the relaxed config
1 parent 010e4e2 commit 45dbeac

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Sanitize itself has no breaking API changes in this release, but the major versi
1010

1111
- 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).
1212

13+
- Added the `@container` CSS at-rule to the relaxed config.
14+
1315
- Added the `-webkit-text-fill-color` CSS property to the relaxed config. [@radar - #244](https://github.com/rgrove/sanitize/pull/244)
1416

1517
### Changed

lib/sanitize/config/relaxed.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ module Config
6363
-moz-keyframes
6464
-o-keyframes
6565
-webkit-keyframes
66+
container
6667
document
6768
keyframes
6869
media

test/test_sanitize_css.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,41 @@
329329
).strip
330330
end
331331

332+
it "preserves allowlisted @container at-rules" do
333+
# Sample code courtesy of MDN:
334+
# https://developer.mozilla.org/en-US/docs/Web/CSS/@container
335+
css = %(
336+
@container (width > 400px) {
337+
h2 {
338+
font-size: 1.5em;
339+
}
340+
}
341+
342+
/* with an optional <container-name> */
343+
@container tall (height > 30rem) {
344+
h2 {
345+
line-height: 1.6;
346+
}
347+
}
348+
349+
/* multiple queries in a single condition */
350+
@container (width > 400px) and style(--responsive: true) {
351+
h2 {
352+
font-size: 1.5em;
353+
}
354+
}
355+
356+
/* condition list */
357+
@container card (width > 400px), style(--responsive: true) {
358+
h2 {
359+
font-size: 1.5em;
360+
}
361+
}
362+
).strip
363+
364+
_(@relaxed.stylesheet(css).strip).must_equal css
365+
end
366+
332367
describe "when blockless at-rules are allowlisted" do
333368
before do
334369
@scss = Sanitize::CSS.new(Sanitize::Config.merge(Sanitize::Config::RELAXED[:css], {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy