MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / $$TestabilityProvider

Function $$TestabilityProvider

code/songhop/www/lib/angular/angular.js:16020–16133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16018}
16019
16020function $$TestabilityProvider() {
16021 this.$get = ['$rootScope', '$browser', '$location',
16022 function($rootScope, $browser, $location) {
16023
16024 /**
16025 * @name $testability
16026 *
16027 * @description
16028 * The private $$testability service provides a collection of methods for use when debugging
16029 * or by automated test and debugging tools.
16030 */
16031 var testability = {};
16032
16033 /**
16034 * @name $$testability#findBindings
16035 *
16036 * @description
16037 * Returns an array of elements that are bound (via ng-bind or {{}})
16038 * to expressions matching the input.
16039 *
16040 * @param {Element} element The element root to search from.
16041 * @param {string} expression The binding expression to match.
16042 * @param {boolean} opt_exactMatch If true, only returns exact matches
16043 * for the expression. Filters and whitespace are ignored.
16044 */
16045 testability.findBindings = function(element, expression, opt_exactMatch) {
16046 var bindings = element.getElementsByClassName('ng-binding');
16047 var matches = [];
16048 forEach(bindings, function(binding) {
16049 var dataBinding = angular.element(binding).data('$binding');
16050 if (dataBinding) {
16051 forEach(dataBinding, function(bindingName) {
16052 if (opt_exactMatch) {
16053 var matcher = new RegExp('(^|\\s)' + escapeForRegexp(expression) + '(\\s|\\||$)');
16054 if (matcher.test(bindingName)) {
16055 matches.push(binding);
16056 }
16057 } else {
16058 if (bindingName.indexOf(expression) != -1) {
16059 matches.push(binding);
16060 }
16061 }
16062 });
16063 }
16064 });
16065 return matches;
16066 };
16067
16068 /**
16069 * @name $$testability#findModels
16070 *
16071 * @description
16072 * Returns an array of elements that are two-way found via ng-model to
16073 * expressions matching the input.
16074 *
16075 * @param {Element} element The element root to search from.
16076 * @param {string} expression The model expression to match.
16077 * @param {boolean} opt_exactMatch If true, only returns exact matches

Callers

nothing calls this directly

Calls 2

forEachFunction · 0.70
escapeForRegexpFunction · 0.70

Tested by

no test coverage detected