-
-
Notifications
You must be signed in to change notification settings - Fork 832
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Stencil Version
4.39.0 (regression from 4.38.3)
Current Behavior
When a component stylesheet contains CSS escape sequences for control characters (for example, icon font declarations using content: "\f101";), the generated *.entry.js now embeds the stylesheet inside a template literal without re-escaping the backslash. This emits literal form-feed characters (ASCII 0x0C) into the <style> tag at runtime.
Browsers treat the control character as invalid CSS and discard the entire <style> block, so every rule in that stylesheet stops applying.
Expected Behavior
Escaped sequences inside component CSS should remain escaped in the emitted bundle (e.g., \f101 in the final string) so browsers parse the stylesheet normally, just as they did in 4.38.3.
System Info
System: node 22.16.0
Platform: darwin (24.6.0)
Build: 1765277402
Stencil: 4.39.0 🎭
TypeScript: 5.8.3
Rollup: 4.34.9
Parse5: 7.2.1
jQuery: 4.0.0-pre
Terser: 5.37.0
npm: 10.8.2
Browsers tested: Chrome 130Steps to Reproduce
- Create a new Stencil component with styleUrl: 'test.css'.
- In test.css, add a rule that includes a Unicode escape, e.g.:
.icon::before { content: "\f101"; } - Build with Stencil 4.39.0 (npm run build).
- Inspect the generated bundle (e.g., dist/components/my-component.entry.js). The CSS string is now a template literal containing a literal form-feed character instead of the escaped \f101.
- Load the component in any browser; the <style> tag injected for the component is ignored entirely because of the control character.
Code Reproduction URL
https://github.com/genadis/stencil-css-escape-bug/blob/main/src/components/app-home/app-home.css#L10
Additional Information
- 4.38.3 serialized CSS with JSON.stringify, which escaped control characters; 4.39.0’s tag-transform work (feat: tag transform / PR feat: tag transform #6211) changed src/compiler/style/css-to-esm.ts to emit template literals without re-escaping, which introduces the raw 0x0C characters.
- Per CSS Syntax Level 3 §4.3.7, control characters must be escaped; otherwise the stylesheet is invalidated.
- Clone and npm run start the reproduction project.
- offending line: https://github.com/genadis/stencil-css-escape-bug/blob/main/src/components/app-home/app-home.css#L10