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

document.body.style called before body exists #38

Open
FossPrime opened this issue Mar 6, 2014 · 9 comments
Open

document.body.style called before body exists #38

FossPrime opened this issue Mar 6, 2014 · 9 comments

Comments

@FossPrime
Copy link

Uncaught TypeError: Cannot read property 'style' of null

... Move is initialized before body exists. There are workarounds... non of which should be necessary.

Line 284
var styl = document.body.style;

@yields yields self-assigned this Mar 6, 2014
@yields
Copy link
Contributor

yields commented Mar 6, 2014

thanks for reporting,

yeah in general you should use defer until the body exists, you can either include the script after the body is loaded or body.onload or something.

examples should be fixed by me but i'm super lazy :P

@yields yields closed this as completed Mar 7, 2014
@hems
Copy link

hems commented Jul 1, 2014

I still get this error, how come the issue is closed?

@DevJS
Copy link

DevJS commented Aug 11, 2014

Hi there,

I still get this error : "Uncaught TypeError: Cannot read property 'style' of null " at the exact same line specified above. Is there any fix ?

Thanks,
Loris1634

@yields yields reopened this Aug 11, 2014
@yields
Copy link
Contributor

yields commented Aug 11, 2014

@hems @Loris1634

can you guys come up with a tiny html file that reproduces it ?

@DevJS
Copy link

DevJS commented Aug 11, 2014

Yep. Here it is : http://pastebin.com/2UYcwjsB

I was not really accurate earlier. Here is the exact error I get : TypeError: document.body is null move.js:284 (I am using Firefox)

@felquis
Copy link

felquis commented Sep 1, 2014

To solve this error, just put move.js before </body> :) Works like a charm!

@hems
Copy link

hems commented Sep 1, 2014

@felquis some people don't include the js on the html source..

@dortzur
Copy link

dortzur commented Jan 16, 2017

Hey, we just encountered this bug in the nastiest of ways: Our module is loaded in the head but MoveJS is only invoked later on runtime.

This resulted in a race condition where we would function normally most of the time, but if we loaded faster than the dom we would get this error.

We would like to issue a pull request to at least workaround this issue. Perhaps an optional flag to skip to document.body.style check.

What do you think?

@jinkwon
Copy link

jinkwon commented Mar 7, 2017

I have same issue. :(

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

7 participants