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

DOMElement - Invalid style properties are not ignored #7920

Closed
adir-n opened this issue Feb 17, 2019 · 3 comments
Closed

DOMElement - Invalid style properties are not ignored #7920

adir-n opened this issue Feb 17, 2019 · 3 comments
Labels

Comments

@adir-n
Copy link

adir-n commented Feb 17, 2019

🐛 Bug Report

When creating a DOM element from a string (by setting innerHTML), an invalid property in style should be ignored, but it is not.

To Reproduce

Set invalid value for a property in the style attribute of an element:

var parent = document.createElement("div");
parent.innerHTML = '<div style="font-size:1r5px">some text<div>';

Expected behavior

The style length of the child element (created in by setting innerHTML) should be 0:

var element = parent.querySelector("div");
expect(element.style.length).toBe(0);

Link to repl or repo (highly encouraged)

link to repo

The test "length of invalid style should be 0" should pass, but it fails.

Run npx envinfo --preset jest

  System:
    OS: Windows 7
    CPU: (4) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  Binaries:
    Node: 10.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.3.2 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
@jeysal
Copy link
Contributor

jeysal commented Feb 17, 2019

Thanks for the bug report and that you took some time to make a minimal repro.
It looks like this issue concerns jsdom, which is the DOM implementation Jest uses, rather than Jest itself, so please open an issue there :)
BTW your innerHTML has <div> instead of </div> at the end, which makes things a bit confusing because there's suddenly multiple divs.

@adir-n
Copy link
Author

adir-n commented Feb 18, 2019

@jeysal thanks for the response (and for noticing my mistake with the </div>).
I opened an issue for jsdom - jsdom/jsdom#2513.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants