Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

document.readyState == 'interactive' is invalid DOM ready test in IE10 #136

Closed
shogun70 opened this issue Apr 28, 2013 · 3 comments
Closed

Comments

@shogun70
Copy link

This relates to a bug in the v2.0 branch.

/complete|interactive/.test(document.readyState) and document.onreadystatechange are not reliable as DOM ready tests. All versions of IE can have interactive state before the DOM is fully loaded. Also, readystatechange can fire before the DOM is fully loaded.

I have written an exploratory test which is sufficient to confirm this bug.

https://gist.github.com/shogun70/5388420

The jQuery project also has a bug report -
document ready is fired too early on IE 9/10
and a "fix" -
sometimes IE10 and lower have document.readyState == "interactive" way too early

domReady also has a report and fix -
Add Guard for invalid readyState in IE9 and IE10

@shogun70
Copy link
Author

Also, Opera doesn't fire the readystatechange event on document.

CORRECTION: document.onreadystatechange fires after window.onload.
I've updated the test:
https://gist.github.com/shogun70/5388420

@jansepar
Copy link
Contributor

@shogun70 thanks for the test case! I will look into this and come up with the appropriate fix asap!

@shogun70
Copy link
Author

Unlike DOMContentLoaded and readystatechange, window.onload is supported on all recent and almost all older browsers. When mobify.js is able to run on older browsers then a window.onload solution won't need to be updated.

Because there is no content, images or styles to download and / or render, I would assume that window.onload is not significantly later than any other event that could be used.

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

No branches or pull requests

2 participants