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.

Inline style of the element is not returned anymore with `.style`

See original GitHub issue

Basic 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Zirrocommented, Nov 27, 2018

This is due to the _attrModified hook added in https://github.com/jsdom/jsdom/commit/064527e2cbc003debe0bc826f893519f1ceb64bc, where I missed the need to include super._attrModified. I’ll create a fix for this later today.

0reactions
minas90commented, Nov 27, 2018

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'

Read more comments on GitHub >

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

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