You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a React app. In React there's a useId() method which is used to generate unique id attributes for DOM elements. The values that useId() generates have colons (:), eg. <div id=":r1:" />.
It looks like happy-dom doesn't handle these very nicely and when you try to query elements by an ID with colons, happy-dom returns you back incorrect results.
To Reproduce
Use the following code:
// Create a div with an "id" with a colonconstel=document.createElement('div',{id: ':r1'});// Append it to the bodydocument.body.appendChild(el);// BUG: Query element by id in `happy-dom`console.log(document.querySelector(CSS.escape(':r1:')).outerHTML);// -> Expecting this to return the <div> I created, but it actually returns the root <html> element// BUG: Similarly, if you do this:console.log(document.body.closest(CSS.escape(':r1:')));// -> I would expect it to return `null` because document.body doesn't have any parents with such an ID, but it weirdly returns the <body> element
Expected behavior
See notes above
Screenshots
N/A
Device:
OS: MacOS
Browser: Node.js
Version: happy-dom@9.9.2
The text was updated successfully, but these errors were encountered:
Describe the bug
I'm building a React app. In React there's a
useId()
method which is used to generate uniqueid
attributes for DOM elements. The values thatuseId()
generates have colons (:
), eg.<div id=":r1:" />
.It looks like
happy-dom
doesn't handle these very nicely and when you try to query elements by an ID with colons,happy-dom
returns you back incorrect results.To Reproduce
Use the following code:
Expected behavior
See notes above
Screenshots
N/A
Device:
The text was updated successfully, but these errors were encountered: