Sha256: cb5c40dda2acade8680a00e7f0f5d3b9664c41317f03e73a5c05048465fc660f

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

// This script is injected from waiter.rb.  It is responsible for setting
// window.capybaraAngularReady when either a) angular is ready, or b)
// it determines the page is not an angular page.

(function () {
  "use strict";

  window.capybaraAngularReady = false;

  function ready() {
    window.capybaraAngularReady = true;
  }

  function angularPresent() {
    return window.angular !== undefined;
  }

  function element() {
    return document.querySelector("[ng-app], [data-ng-app]") || document.querySelector("body");
  }

  function elementPresent() {
    return element() !== undefined;
  }

  function setupTestability() {
    try {
      angular.getTestability(element()).whenStable(ready);
    } catch (err) {
      ready();
    }
  }

  function setupInjector() {
    try {
      angular.element(element()).injector().get("$browser").notifyWhenNoOutstandingRequests(ready);
    } catch (err) {
      ready();
    }
  }

  function setup() {
    if (!angularPresent() || !elementPresent()) {
      ready();
    } else if (angular.getTestability) {
      setupTestability();
    } else {
      setupInjector();
    }
  }

  setup();
}());

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capybara-angular-0.3.0 lib/capybara/angular/waiter.js
capybara-angular-0.2.6 lib/capybara/angular/waiter.js