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

Comments are not instances of Comment when using GlobalRegistrator #1580

Open
danieldiekmeier opened this issue Nov 4, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@danieldiekmeier
Copy link

Describe the bug

When using GlobalRegistrator, instanceof Comment is always false, because the globally defined Comment is not the same as the one that is actually used to create comment instances.

Svelte 5 does this check somewhere deep in their template handling – that's how I stumbled upon the problem. I first thought it was a problem with Svelte Testing Library, see issue #407 over there.

To Reproduce

import { GlobalRegistrator } from '@happy-dom/global-registrator'
import { Comment as DirectComment } from 'happy-dom'

GlobalRegistrator.register({ url: 'http://localhost:3000', width: 1920, height: 1080 })

const elem = document.createElement('template')
elem.innerHTML = '<!-- hello -->'
const comment = elem.content.firstChild

console.log(comment instanceof Comment) // BUG: this prints `false`
console.log(comment instanceof DirectComment) // this prints `true`

Expected behavior

I expect (comment instanceof Comment) === true.

Device:

  • OS: macOS 15.0.1
  • Node 22.11.0
  • happy-dom: 15.8.3
  • @happy-dom/global-registrator: 15.8.3
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

1 participant