Sha256: f6d1ae0a781b0fe1cdb2ec42668291b0532f3abeddad7820c78340cea2e1a0f9

Contents?: true

Size: 951 Bytes

Versions: 4

Compression:

Stored size: 951 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);
  }, 1000);
}

// 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

4 entries across 4 versions & 1 rubygems

Version Path
watir-dom-wait-0.3.3 lib/watir/dom/extensions/js/waitForDom.js
watir-dom-wait-0.3.2 lib/watir/dom/extensions/js/waitForDom.js
watir-dom-wait-0.3.1 lib/watir/dom/extensions/js/waitForDom.js
watir-dom-wait-0.3.0 lib/watir/dom/extensions/js/waitForDom.js