Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML is incorrect after using style.setProperty(n, v, 'important') #2649

Open
Rich-Harris opened this issue Aug 20, 2019 · 1 comment · May be fixed by jsdom/cssstyle#152
Open

HTML is incorrect after using style.setProperty(n, v, 'important') #2649

Rich-Harris opened this issue Aug 20, 2019 · 1 comment · May be fixed by jsdom/cssstyle#152

Comments

@Rich-Harris
Copy link
Contributor

Basic info:

  • Node.js version: 11.6.0
  • jsdom version: 15.1.1

Minimal reproduction case

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

const div = window.document.createElement('div');

div.style.setProperty('color', 'red', 'important');
assert.equal(
  div.outerHTML,
  `<div style="color: red !important;"></div>`
); // fails — equals `<div style="color: red;"></div>`

div.style.setProperty('font-size', '20px', 'important');
assert.equal(
  div.outerHTML,
  `<div style="color: red !important; font-size: 20px !important;"></div>`
); // fails — equals `<div style="color: red !important; font-size: 20px;"></div>`

How does similar code behave in browsers?

The !important priority is added to each style property. In JSDOM, if the final property has !important, it is omitted.

https://jsbin.com/liquwabetu/edit?html,output

@Sebmaster
Copy link
Member

I think this is actually a bug in cssstyle since jsdom just source the whole CSSStyleDeclaration from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants