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

Use doc.documentElement instead of doc.body #711

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@devinrhode2

devinrhode2 commented Sep 12, 2016

If elm is initialized in javascript above the <body> tag, document.body will be null, causing the renderer to fail with this error message: Uncaught TypeError: Cannot read property 'appendChild' of null. The Renderer is trying to call appendChild on the rootDomNode, which is null if it's document.body. Here's my commit where I was stuck on this

I think we can simply use document.documentElement instead of document.body, assuming there aren't other additional direct references to document.body. I tested this by directly editing the built elm.js file and it worked well.

Use doc.documentElement instead of doc.body
If elm is initialized in javascript above the `<body>` tag, `document.body` will be null, elm crash in the renderer and the screen will be blank: `Uncaught TypeError: Cannot read property 'appendChild' of null `. The Renderer is trying to call appendChild on the rootDomNode, which is null if it's document.body. [Here's my commit where I was stuck on this](https://github.com/devinrhode2/structured-elm-todomvc/tree/47abbf1083bc9db806323cca1912f3c4a0828e7b)

I think we can simply use `document.documentElement`, assuming there aren't other additional references to `document.body`. I tested this by directly editing the built elm.js file and it worked well.
@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Sep 12, 2016

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Sep 12, 2016

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz May 22, 2018

Member

I think the current behavior makes more sense. I think it is reasonable to run the Elm program after the body exists.

Member

evancz commented May 22, 2018

I think the current behavior makes more sense. I think it is reasonable to run the Elm program after the body exists.

@evancz evancz closed this May 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment