@supports rules causes Error: Could not parse CSS stylesheet
See original GitHub issueBasic info:
- Node.js version: 8.5.0
- jsdom version: 11.3.0
Minimal reproduction case
const { JSDOM } = require("jsdom");
new JSDOM(`<style>
@supports (text-decoration-style: solid) {
ul.toc a:hover, ul.toc a:focus {
}
}
</style>`)
This results in this console output:
Error: Could not parse CSS stylesheet
at exports.evaluateStylesheet (/redacted/node_modules/jsdom/lib/jsdom/living/helpers/stylesheets.js:18:21)
at HTMLStyleElementImpl._attach (/redacted/node_modules/jsdom/lib/jsdom/living/nodes/HTMLStyleElement-impl.js:23:5)
at HTMLHeadElementImpl._attach (/redacted/node_modules/jsdom/lib/jsdom/living/nodes/Node-impl.js:281:15)
at HTMLHeadElementImpl._attach (/redacted/node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js:90:11)
at HTMLHtmlElementImpl._attach (/redacted/node_modules/jsdom/lib/jsdom/living/nodes/Node-impl.js:281:15)
at HTMLHtmlElementImpl._attach (/redacted/node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js:90:11)
at DocumentImpl.insertBefore (/redacted/node_modules/jsdom/lib/jsdom/living/nodes/Node-impl.js:221:22)
at DocumentImpl.appendChild (/redacted/node_modules/jsdom/lib/jsdom/living/nodes/Node-impl.js:319:17)
at DocumentImpl.appendChild (/redacted/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:394:18)
at setChild (/redacted/node_modules/jsdom/lib/jsdom/browser/htmltodom.js:230:18)
@supports (text-decoration-style: solid) {
ul.toc a:hover, ul.toc a:focus {
}
}
How does similar code behave in browsers?
No console error or warning in Chrome: https://wicg.github.io/hsts-priming/
Source: https://github.com/WICG/hsts-priming/blob/bb84ed97793799ccc50eb36eba1d1e95722f9eb2/index.html#L856
Issue Analytics
- State:
- Created 6 years ago
- Reactions:12
- Comments:11 (2 by maintainers)
Top Results From Across the Web
console.error Error: Could not parse CSS stylesheet
"Could not parse CSS stylesheet" usually means you have some kind of error in your CSS. Without that CSS, we couldn't tell you...
Read more >Common CSS Parser Errors (Parsing Errors Found)
The parser will show a Parse Error and the line number if it detects something that does not meet the requirements. CSS Parser...
Read more >Error! Failed to parse the stylesheet - Adobe Support Community
I am running Robohelp 2019.0.14 and am getting the "Failed to parse the stylesheet' error. How can I identify what the offending code...
Read more >CSS Parse Error: The Ultimate Guide To Eradicating Them
The parse error in CSS arises when the CSS parser detects something that does not comply with the requirements. Usually, a CSS parser...
Read more >CSSStyleSheet.insertRule() - Web APIs | MDN
insertRule() method inserts a new CSS rule into the current style sheet. ... Thrown if rule cannot be inserted at index 0 due...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@devrelm – just running
npm install --save-dev cssomworked for me!Thanks a ton!
This was fixed with NV/CSSOM#94 & NV/CSSOM#96, and available in CSSOM v0.3.3. It looks like
jsdomis just looking for>= 0.3.2 < 0.4.0, so it should be available to end users by updating that sub-dependency.Upgrading the sub-dependency might be easier said than done for some users since there’s no easy way to do it in
yarn(or possibly innpmeither.)I did it with a little manual editing, like so:
yarn add cssomcssomdependencies in myyarn.lock. It should look something like this:version "0.3.2"and following line with itsversion "0.3.3"counterparts. You should be left with a diff like so:package.jsonto remove the direct dependency oncssom(if you don’t need it)yarnto double-check that everything still works and to removecssom@0.3.2.