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

DOMException: Failed to execute 'insertBefore' on 'Node' #1429

Open
marcotas opened this issue May 7, 2024 · 2 comments
Open

DOMException: Failed to execute 'insertBefore' on 'Node' #1429

marcotas opened this issue May 7, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@marcotas
Copy link

marcotas commented May 7, 2024

Describe the bug
I'm getting this error inside radix-vue after updating the happy-dom package from 14.7.1 to 14.10.1. It seems to me that it's a change on the most recent version of happy-dom package that is breaking my unit tests.

Everything works as expected on the browser. How should I solve this? Any ideas?

Screenshots
image

Error text:

DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
 ❯ Function.insertBefore node_modules/.pnpm/happy-dom@14.8.3/node_modules/happy-dom/src/nodes/node/NodeUtility.ts:181:10
 ❯ Function.insertBefore node_modules/.pnpm/happy-dom@14.8.3/node_modules/happy-dom/src/nodes/element/ElementUtility.ts:215:16
 ❯ HTMLElement.[insertBefore] node_modules/.pnpm/happy-dom@14.8.3/node_modules/happy-dom/src/nodes/element/Element.ts:522:25
 ❯ HTMLElement.insertBefore node_modules/.pnpm/happy-dom@14.8.3/node_modules/happy-dom/src/nodes/node/Node.ts:367:43
 ❯ HTMLElement.insertAdjacentElement node_modules/.pnpm/happy-dom@14.8.3/node_modules/happy-dom/src/nodes/element/Element.ts:601:9
 ❯ node_modules/.pnpm/radix-vue@1.7.4_vue@3.4.27_typescript@5.4.5_/node_modules/radix-vue/dist/index.js:897:19
    895|       return;
    896|     const t = document.querySelectorAll("[data-radix-focus-guard]");
    897|     document.body.insertAdjacentElement(
       |                   ^
    898|       "afterbegin",
    899|       t[0] ?? Po()
 ❯ callWithErrorHandling node_modules/.pnpm/@vue+runtime-core@3.4.27/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:195:19
 ❯ callWithAsyncErrorHandling node_modules/.pnpm/@vue+runtime-core@3.4.27/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:202:17
 ❯ ReactiveEffect.getter [as fn] node_modules/.pnpm/@vue+runtime-core@3.4.27/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1900:16
 ❯ ReactiveEffect.run node_modules/.pnpm/@vue+reactivity@3.4.27/node_modules/@vue/reactivity/dist/reactivity.cjs.js:181:19

Device:

  • OS: macOS Sonoma 14.4.1
@marcotas marcotas added the bug Something isn't working label May 7, 2024
@btea
Copy link
Contributor

btea commented May 14, 2024

Can you provide a reproduction link?

@alk-sdavid
Copy link

Hi, I have the same issue caused by this recent fix: #1407
I created a repo to reproduce this issue: https://github.com/alk-sdavid/happy-dom-issue (install deps then run npm test).

It logs the same error as Marco commented:

DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.

Same test works with happy-dom@14.8.2, then it starts failing with happy-dom@14.8.3

I didn't have time to dig more, but in my use case it craches when I try to test a Radix select rendered in a Radix dialog which uses a React portal...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants