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
This works fine in the browser, but in happy-dom, due to (if I'm reading the code correctly) how subclasses of Node override cloneNode, Svelte v5 fails to properly clone nodes. This is problematic, because cloneNode is used to initially mount components into the DOM.
Svelte calls the following methods through the prototype. From a quick scan of the code, I think cloneNode is the only problematic one, but I'd want to verify through tests.
An easy way to see how things get messed up is to check the tagName of a cloned node. If you use Node.prototype.cloneNode.call, the clone will have a tagName of null, which will break other things internally to happy-dom and downstream.
This issue has already been reported as a feature request in #1165, but I felt it was important to highlight as a bug, because it is a material difference in how happy-dom behaves vs the browser. Feel free to close out as a duplicate if you feel this is already adequately tracked!
The text was updated successfully, but these errors were encountered:
Describe the bug
Hello again! My last experience filing a bug was so good I thought I'd do another one 😄
The upcoming Svelte v5 calls various
Node
andElement
methods through their prototypes to "avoid doing expensive prototype chain lookups."This works fine in the browser, but in happy-dom, due to (if I'm reading the code correctly) how subclasses of
Node
overridecloneNode
, Svelte v5 fails to properly clone nodes. This is problematic, becausecloneNode
is used to initially mount components into the DOM.Svelte calls the following methods through the prototype. From a quick scan of the code, I think
cloneNode
is the only problematic one, but I'd want to verify through tests.Node.prototype.cloneNode
- Does not workNode.prototype.appendChild
- Looks okNode.prototype.firstChild
- Looks okNode.prototype.nextSibling
- Looks okElement.prototype.className
- Looks okRelated to:
happy-dom
test fails with >2 components in a file sveltejs/svelte#10358To Reproduce
An easy way to see how things get messed up is to check the
tagName
of a cloned node. If you useNode.prototype.cloneNode.call
, the clone will have atagName
ofnull
, which will break other things internally to happy-dom and downstream.> node index.js clone1 DIV clone2 null
Expected behavior
I expect the various
Node.prototype
methods, such ascloneNode
, to fully work on all node types, as they do in the browser.Additional context
Tested on
[email protected]
This issue has already been reported as a feature request in #1165, but I felt it was important to highlight as a bug, because it is a material difference in how happy-dom behaves vs the browser. Feel free to close out as a duplicate if you feel this is already adequately tracked!
The text was updated successfully, but these errors were encountered: