JSDOM doesn't retrieve the "*style.backgroundColor = 'pink'" property set on a table row
See original GitHub issueBasic 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:
- Created 6 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top 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 >
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
We don’t support getting the style property as JS properties on
style
for now. You would have to usetr.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.Note, we always try to implement the latest Editor’s Draft, so https://drafts.csswg.org/css-color/#named-colors.