aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-03-06 11:24:59 +0000
committerStephen Blott2016-03-06 11:27:45 +0000
commita8cd9d5b66f9fd6d46f453e50672611538c801f2 (patch)
tree51eddeb78dced1e74524237ac58a7e2d45b2f31a
parent5b2e06747f63fbb120bae527122bd2ea0af9ea7d (diff)
downloadvimium-a8cd9d5b66f9fd6d46f453e50672611538c801f2.tar.bz2
Tweak documentReady().
We can remove these listeners once we're done.
-rw-r--r--lib/dom_utils.coffee8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index aab0a4df..3581bd3f 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -2,11 +2,13 @@ DomUtils =
#
# Runs :callback if the DOM has loaded, otherwise runs it on load
#
- documentReady: (func) ->
+ documentReady: (callback) ->
if document.readyState == "loading"
- window.addEventListener "DOMContentLoaded", func
+ window.addEventListener "DOMContentLoaded", handler = ->
+ window.removeEventListener "DOMContentLoaded", handler
+ callback()
else
- func()
+ callback()
createElement: (tagName) ->
element = document.createElement tagName