diff options
| author | Stephen Blott | 2015-01-12 11:55:20 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2015-01-12 11:55:44 +0000 | 
| commit | 4504b78613b4a68b838dd887c8b23ec5a71fe779 (patch) | |
| tree | ab3e5c5d542045f239715f24aed6f9c0704ae4aa /lib | |
| parent | 9ce07ada32883ac75a1d7436c026a846628181c8 (diff) | |
| download | vimium-4504b78613b4a68b838dd887c8b23ec5a71fe779.tar.bz2 | |
Fix race condition on the options page (better).
Uses document.readyState for all onDOMContentLoaded dependent functions.
This should fix the same race condition as #1426 for all cases.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/dom_utils.coffee | 16 | 
1 files changed, 5 insertions, 11 deletions
| diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 762c6418..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. @@ -178,12 +179,5 @@ 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 | 
