aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorStephen Blott2015-01-14 15:41:04 +0000
committerStephen Blott2015-01-14 15:41:04 +0000
commit0f80b22ca3a072d843cc79eeae71312a5b2eee74 (patch)
tree26cf65bf9ffed0984787a1386454ff1e4dbe09da /lib
parent75565049e160042017486c10a61bed3a292e0c58 (diff)
parent2e8acc1fcd8661fc3f14d86cbf4329b4fc7f843d (diff)
downloadvimium-0f80b22ca3a072d843cc79eeae71312a5b2eee74.tar.bz2
Merge pull request #1427 from smblott-github/fix-race-condition-on-options-page
Fix race condition on the options page.
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 ba5e279f..7a75dd6a 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.