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

element.ownerDocument.documentElement is null onMount in linked package #378

Open
bigmistqke opened this issue Oct 26, 2024 · 1 comment

Comments

@bigmistqke
Copy link
Contributor

bigmistqke commented Oct 26, 2024

With the following snippet:

export const BugCheck =  () => {
  const [documentElement, setDocumentElement] = createSignal<HTMLElement>()
  return (
    <pre
      ref={element => {
        onMount(() => setDocumentElement(element.ownerDocument.documentElement))
      }}
    >
      {documentElement() === null ? 'NULL' : documentElement()?.innerHTML}
    </pre>
  )
}

We get different results in between dev and build when linking the package into a solid app:

Screenshot 2024-10-26 at 15 47 15

element.ownerDocument.documentElement is defined in dev mode, but is null when build.

When delaying it by a frame with requestAnimationFrame we do get the expected result:

Screenshot 2024-10-26 at 15 53 41

When inlining it directly in the app, it also does not give an error, so it's a quite surprising bug. Afaik the bug also does not seem to show up when downloading the published library, only during linking (am i correct in this, @ralphsmith80 ?)

a minimal reproduction of the bug

This bug came apparent during development of solid-plotly.js as plotly-js apparently makes use of this during initialisation.

@ralphsmith80
Copy link

That's correct @bigmistqke. It's only an issue when linking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants