Skip to content

CSS at-rules stripped from inline <style> blocks during build #2

@blizzardengle

Description

@blizzardengle

Summary

All CSS at-rules inside <style> elements are removed during the build. Only rules that are plain selectors (or nested selectors with &) plus declarations are kept. The result is broken animations, no media/container/scope/layer/supports behavior, and empty <style></style> blocks in the output.

  • @keyframes definitions are removed (animations break).
  • @media, @container, @scope, @layer, and @supports blocks are removed (empty <style> tags remain).

What is stripped (broken)

Source (in .jhp) Built output
@keyframes name { ... } Removed. Only rules that reference the animation (e.g. animation: name ...) remain, so animation names resolve to nothing.
@media (...) Removed. The corresponding <style> block is emitted empty.
@container name (...) { ... } Removed. Properties that set up the container (e.g. container-type, container-name) are kept; the @container query block is removed.
@scope (...) to (...) { ... } Removed. <style> block is empty.
@layer name { ... } Removed. <style> block is empty.
@supports (...) { ... } Removed. <style> block is empty.
Any combination of the above (e.g. @keyframes + @media) Removed. Block becomes empty.

So in the built HTML:

  • Block 2: Had @keyframes test-fade, @keyframes test-bounce and .anim-fade / .anim-bounce. Output keeps only .anim-fade and .anim-bounce; keyframe definitions are gone.
  • Block 3: Had two @media blocks. Output: <style></style>.
  • Block 4: Had .test-container-context and @container demo (min-width: 300px) { .cq-wide { ... } }. Output: only .test-container-context; container query removed.
  • Blocks 5, 6, 7: Had @scope, @layer, @supports. Output: three empty <style></style>.
  • Block 9: Had @keyframes test-combo and @media (prefers-reduced-motion: no-preference) { .anim-combo { ... } }. Output: <style></style>.

What is preserved

  • Plain selector rules (e.g. .test-legend, .test-section, .anim-fade).
  • Nested CSS with & (e.g. .test-nested-parent with & .test-nested-child, & > .test-nested-direct).
  • Inline style attributes on elements.
  • <script type="text/javascript"> and <script type="module"> content (passed through when script has an attribute; see note below).
  • HTML structure, SVG, <pre>/<code>, comments.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions