CSSStyleSheet does not have ownerNode or href properties.
See original GitHub issueI know this project has a disclaimer about not supporting all of the CSSOM, but I encountered some errors while trying to get HTML Inspector to work with jsdom instead of PhatomJS, and I tracked it down to the lack of these two properties on the CSSStyleSheet
object.
From what I can tell, the following function in level2/style.js is where this could/should be added, but I’m not familiar enough with the codebase to know for sure.
function evaluateStylesheet(data, sheet, baseUrl) {
// this is the element
var newStyleSheet = cssom.parse(data);
var spliceArgs = newStyleSheet.cssRules;
spliceArgs.unshift(0, sheet.cssRules.length);
Array.prototype.splice.apply(sheet.cssRules, spliceArgs);
scanForImportRules.call(this, sheet.cssRules, baseUrl);
// Add references to `this` and `baseUrl`.
sheet.href = baseUrl;
sheet.ownerNode = this;
this.ownerDocument.styleSheets.push(sheet);
}
Anyway, this changed work for me locally, so hopefully it’s as simple as that. Thanks for the consideration.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:6
- Comments:6 (1 by maintainers)
Top Results From Across the Web
StyleSheet.ownerNode - Web APIs | MDN
The ownerNode property of the StyleSheet interface returns the node that associates this style sheet with the document.
Read more >Getting stylesheet object from ownerNode(style tag)
How can I get the styleSheet as in document.styleSheets object from a style element. A way could be scanning all the styleSheets in...
Read more >Optional: Accessing Stylesheets in the CSSOM
Your project may have multiple stylesheets, so you'll need to verify ... If the stylesheet's href property does not have "styles.css" in it, ......
Read more >CSSStyleSheet (Java SE 10 & JDK 10 ) - Oracle Help Center
If this style sheet comes from an @import rule, the ownerRule attribute will contain the CSSImportRule . In that case, the ownerNode attribute...
Read more >Add Rules to Stylesheets with JavaScript - David Walsh Blog
A CSSStyleSheet object does have informational properties for you to ... MediaList ownerNode: link ownerRule: null parentStyleSheet: null ...
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 FreeTop 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
Top GitHub Comments
Hello I was about to file an issue for this, ownerNode is still not supported right? If it is the case I will be happy to try to add it Thx !
@lexoyo I also need this and have been trying to look into it - but not sure how…
There is a file, HTMLStyleElement-impl.js, that calls createStylesheet() in helpers > stylesheet.js and here is a bunch of garbage and TODO’s.
It seems to me that “cssom” should be used instead, which (seem to) have what we need - but, not sure how at the moment. Also I don’t have more time, so I will investigate further if I can get some more time. If you figure it out, please let me know!