question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSSStyleSheet does not have ownerNode or href properties.

See original GitHub issue

I 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:open
  • Created 9 years ago
  • Reactions:6
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
lexoyocommented, Feb 13, 2018

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 !

4reactions
OlofTcommented, May 8, 2018

@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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found