Inline style of the element is not returned anymore with `.style`
See original GitHub issueBasic info:
- Node.js version: 10.13.0
- jsdom version: 13.0.0
Minimal reproduction case
const { JSDOM } = require("jsdom");
const dom = new JSDOM('<a style="display:none;color:red;" href="https://google.com">google.com</a>');
console.log(document.querySelector('a').style)
Hi there,
It’s no longer possible to get style of the element with .style
, as a workaround el.getAttribute('style')
works properly, but .style
breaks our code in many places.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Override Inline Styles with CSS
Often we think of inline styles as a way to override styles we set up in the CSS. 99% of the time, this...
Read more >Avoiding Inline Styles for CSS Design - ThoughtCo
Inline styles, while they have a purpose, are not the best way to maintain your website. Learn how following best practices for CSS...
Read more >Use inline style in React with plain CSS string - Stack Overflow
In AngularJS this was no problem, I just set the 'style' attribute to the given string. In ReactJS I cannot do this anymore,...
Read more >Why you shouldn't use inline styling in production React apps
One of the main reasons that inline styling is not a good choice for your application is because it does not support (or...
Read more >HTMLElement.style - Web APIs | MDN
The style read-only property returns the inline style of an element in the form of a CSSStyleDeclaration object that contains a list of...
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
This is due to the
_attrModified
hook added in https://github.com/jsdom/jsdom/commit/064527e2cbc003debe0bc826f893519f1ceb64bc, where I missed the need to includesuper._attrModified
. I’ll create a fix for this later today.Yes, the log will not hit, downgrading to 12.2.0 fixes that. I’m also not sure what changed, but it broke our code in many places, we are removing hidden elements by checking if
a.style.display === 'none'