Permalink
Browse files

Ensure `ready` always fires on IE 10

IE 10 is reported to have weird states re: `readyState` and regarding
DOMContentLoaded has already been fired or not. In case we are too late
to register the DOMContentLoaded handler (the event already fired), also
register a `window.onload` handler as fallback.

Closes #1240, ref. #1235
  • Loading branch information...
1 parent 0283a32 commit 32094dc08a7b08517e41d7e05ab4e152e5c5e3a1 @mislav mislav committed Nov 22, 2016
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/zepto.js
View
@@ -440,8 +440,15 @@ var Zepto = (function() {
if (document.readyState === "complete" ||
(document.readyState !== "loading" && !document.documentElement.doScroll))
setTimeout(function(){ callback($) }, 0)
- else
- document.addEventListener("DOMContentLoaded", function(){ callback($) }, false)
+ else {
+ var handler = function() {
+ document.removeEventListener("DOMContentLoaded", handler, false)
+ window.removeEventListener("load", handler, false)
+ callback($)
+ }
+ document.addEventListener("DOMContentLoaded", handler, false)
+ window.addEventListener("load", handler, false)
+ }
return this
},
get: function(idx){

0 comments on commit 32094dc

Please sign in to comment.