aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorStephen Blott2015-01-12 11:47:56 +0000
committerStephen Blott2015-01-12 11:47:56 +0000
commit9ce07ada32883ac75a1d7436c026a846628181c8 (patch)
tree62ee77ec6688cbfa7bd2ddcf01b6f61054d02dd0 /lib
parent75565049e160042017486c10a61bed3a292e0c58 (diff)
downloadvimium-9ce07ada32883ac75a1d7436c026a846628181c8.tar.bz2
Fix race condition on the options page.
Fixes #1426.
Diffstat (limited to 'lib')
-rw-r--r--lib/dom_utils.coffee7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index ba5e279f..762c6418 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -178,5 +178,12 @@ DomUtils =
event.preventDefault()
@suppressPropagation(event)
+ # Calls func either now (if the DOM has already loaded), or when the DOM is loaded.
+ runWhenDOMLoaded: (func) ->
+ if document.readyState == "loading"
+ window.addEventListener "DOMContentLoaded", func
+ else
+ func()
+
root = exports ? window
root.DomUtils = DomUtils