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`
Describe the bug
When using
GlobalRegistrator
,instanceof Comment
is alwaysfalse
, because the globally definedComment
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
Expected behavior
I expect
(comment instanceof Comment) === true
.Device: