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.

JSDOM doesn't retrieve the "*style.backgroundColor = 'pink'" property set on a table row

See original GitHub issue

Basic info:

  • Node.js version: 8.1.2
  • jsdom version: 11.2.0

Minimal reproduction case

const { JSDOM } = require("jsdom");

const document = new JSDOM(`
    <table>
      <thead>
        <tr><th>Time</th></tr>
        <tr><th>Customer Name</th></tr>
      </thead>
      <tbody>
        <tr><td>...</td><td>Ricki</td></tr>
        <tr><td>...</td><td>Ricki</td></tr>
        <tr><td>...</td><td>Anna</td></tr>
      </tbody>
    </table>
  `).window.document;

[].slice.call(document.querySelectorAll('tr')).forEach((tr) => { return tr.style.backgroundColor = 'pink'; });

// Expected to have an array of "pink" but got an array of empty values
// Result: [ '', '', '', '', '' ]
console.log([].slice.call(document.querySelectorAll('tr')).map((tr) => { return tr.style.backgroundColor; }));

How does similar code behave in browsers?

The same code works in the browser: https://jsfiddle.net/r0u9p0uv/

Am I missing something?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
TimothyGucommented, Aug 31, 2017

We don’t support getting the style property as JS properties on style for now. You would have to use tr.style.getPropertyValue(). I believe @Zirro is working on a rewrite of the entire CSSOM support in jsdom, though, which should bring support for this feature.

0reactions
TimothyGucommented, Aug 31, 2017

Note, we always try to implement the latest Editor’s Draft, so https://drafts.csswg.org/css-color/#named-colors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jsDOM cannot change background color by class or tag
I have tried using getElementsByTagName and getElementsByClassName after which I use the style property then backgroundColor of course. ( ...
Read more >
Reactive Web App - Conditionally styling in the Table properties
I'm trying to add a conditional style for a table row by making the background pink. I am expecting rows where Employees are...
Read more >
tripledollar - NPM Package Overview - Socket - Socket.dev
Function element.set(String, Function) -> element-reference ... One thing you can't do is having property names like 'background-color', because the dash is ...
Read more >
JSDOMからピンクを探せ!! - Qiita
... ぜ」ってイシューが建てられていました。 JSDOM doesn't retrieve the "*style.backgroundColor = 'pink'" property set on a table row #1965 ...
Read more >
HTML | <tr> bgcolor Attribute - GeeksforGeeks
The HTML <tr> bgcolor Attribute is used to specify the background color of a table row. It is not supported by HTML 5....
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