aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/dom_utils.coffee9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index e1f1f442..aee2f972 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -2,10 +2,11 @@ DomUtils =
#
# Runs :callback if the DOM has loaded, otherwise runs it on load
#
- documentReady: do ->
- loaded = false
- window.addEventListener("DOMContentLoaded", -> loaded = true)
- (callback) -> if loaded then callback() else window.addEventListener("DOMContentLoaded", callback)
+ documentReady: (func) ->
+ if document.readyState == "loading"
+ window.addEventListener "DOMContentLoaded", func
+ else
+ func()
#
# Adds a list of elements to a page.