diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/domUtils.js | 14 | 
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/domUtils.js b/lib/domUtils.js index fd182c59..159867d9 100644 --- a/lib/domUtils.js +++ b/lib/domUtils.js @@ -1,4 +1,18 @@  var domUtils = { +  /** +   * Runs :callback if the DOM has loaded, otherwise runs it on load +   */ +  documentReady: (function() { +    var loaded = false; +    window.addEventListener("DOMContentLoaded", function() { loaded = true; }); +    return function(callback) { +      if (loaded) +        callback(); +      else +        window.addEventListener("DOMContentLoaded", callback); +    }; +  })(), +    /*     * Takes an array of XPath selectors, adds the necessary namespaces (currently only XHTML), and applies them     * to the document root. The namespaceResolver in evaluateXPath should be kept in sync with the namespaces  | 
