Sha256: 5a7fb3e5e843be0fb826867b13d69226394b1874f018bb921e284c846ed1da98

Contents?: true

Size: 952 Bytes

Versions: 1

Compression:

Stored size: 952 Bytes

Contents

/**
 * Disconnects observer and invokes WebDriver's callback function
 * to show that DOM has started modifying.
 */
var exitOnStartedModifying = function() {
  clearTimeout(exitOnNotStartedModifying);
  observer.disconnect();
  callback(false);
}

/**
 * Disconnects observer and invokes WebDriver's callback function
 * to show that DOM has not started modifying.
 */
var exitOnNotStartedModifying = function() {
  return setTimeout(function() {
    observer.disconnect();
    callback(true);
  }, delay);
}

// arguments from WebDriver
var element  = arguments[0];
var delay    = arguments[1] * 1000;
var callback = arguments[2];

// start observer
var observer = new MutationObserver(exitOnStartedModifying);
var config = { attributes: true, childList: true, characterData: true, subtree: true };
observer.observe(element, config);

// make sure we exit if DOM has not started modifying
var exitOnNotStartedModifying = exitOnNotStartedModifying();

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir-dom-wait-0.4.0 lib/watir/dom/extensions/js/waitForDom.js