@@ -22,11 +22,11 @@ var functions = {};
22
22
*
23
23
* Asynchronous.
24
24
*
25
- * @param {string } selector The selector housing an ng-app
25
+ * @param {string } rootSelector The selector housing an ng-app
26
26
* @param {function } callback callback
27
27
*/
28
- functions . waitForAngular = function ( selector , callback ) {
29
- var el = document . querySelector ( selector ) ;
28
+ functions . waitForAngular = function ( rootSelector , callback ) {
29
+ var el = document . querySelector ( rootSelector ) ;
30
30
try {
31
31
if ( angular . getTestability ) {
32
32
angular . getTestability ( el ) . whenStable ( callback ) ;
@@ -50,10 +50,10 @@ functions.waitForAngular = function(selector, callback) {
50
50
* @return {Array.<Element> } The elements containing the binding.
51
51
*/
52
52
functions . findBindings = function ( binding , exactMatch , using , rootSelector ) {
53
- rootSelector = rootSelector || 'body' ;
54
- using = using || document . querySelector ( rootSelector ) ;
53
+ var root = document . querySelector ( rootSelector || 'body' ) ;
54
+ using = using || document ;
55
55
if ( angular . getTestability ) {
56
- return angular . getTestability ( using ) .
56
+ return angular . getTestability ( root ) .
57
57
findBindings ( using , binding , exactMatch ) ;
58
58
}
59
59
var bindings = using . getElementsByClassName ( 'ng-binding' ) ;
@@ -86,14 +86,12 @@ functions.findBindings = function(binding, exactMatch, using, rootSelector) {
86
86
* @param {string } repeater The text of the repeater, e.g. 'cat in cats'.
87
87
* @param {number } index The row index.
88
88
* @param {Element } using The scope of the search.
89
- * @param {string } rootSelector The selector to use for the root app element.
90
89
*
91
90
* @return {Array.<Element> } The row of the repeater, or an array of elements
92
91
* in the first row in the case of ng-repeat-start.
93
92
*/
94
- functions . findRepeaterRows = function ( repeater , index , using , rootSelector ) {
95
- rootSelector = rootSelector || 'body' ;
96
- using = using || document . querySelector ( rootSelector ) ;
93
+ functions . findRepeaterRows = function ( repeater , index , using ) {
94
+ using = using || document ;
97
95
98
96
var prefixes = [ 'ng-' , 'ng_' , 'data-ng-' , 'x-ng-' , 'ng\\:' ] ;
99
97
var rows = [ ] ;
@@ -137,13 +135,11 @@ functions.findBindings = function(binding, exactMatch, using, rootSelector) {
137
135
*
138
136
* @param {string } repeater The text of the repeater, e.g. 'cat in cats'.
139
137
* @param {Element } using The scope of the search.
140
- * @param {string } rootSelector The selector to use for the root app element.
141
138
*
142
139
* @return {Array.<Element> } All rows of the repeater.
143
140
*/
144
- functions . findAllRepeaterRows = function ( repeater , using , rootSelector ) {
145
- rootSelector = rootSelector || 'body' ;
146
- using = using || document . querySelector ( rootSelector ) ;
141
+ functions . findAllRepeaterRows = function ( repeater , using ) {
142
+ using = using || document ;
147
143
148
144
var rows = [ ] ;
149
145
var prefixes = [ 'ng-' , 'ng_' , 'data-ng-' , 'x-ng-' , 'ng\\:' ] ;
@@ -190,8 +186,8 @@ functions.findBindings = function(binding, exactMatch, using, rootSelector) {
190
186
*/
191
187
functions . findRepeaterElement = function ( repeater , index , binding , using , rootSelector ) {
192
188
var matches = [ ] ;
193
- rootSelector = rootSelector || 'body' ;
194
- using = using || document . querySelector ( rootSelector ) ;
189
+ var root = document . querySelector ( rootSelector || 'body' ) ;
190
+ using = using || document ;
195
191
196
192
var rows = [ ] ;
197
193
var prefixes = [ 'ng-' , 'ng_' , 'data-ng-' , 'x-ng-' , 'ng\\:' ] ;
@@ -234,7 +230,7 @@ functions.findRepeaterElement = function(repeater, index, binding, using, rootSe
234
230
if ( angular . getTestability ) {
235
231
matches . push . apply (
236
232
matches ,
237
- angular . getTestability ( using ) . findBindings ( row , binding ) ) ;
233
+ angular . getTestability ( root ) . findBindings ( row , binding ) ) ;
238
234
} else {
239
235
if ( row . className . indexOf ( 'ng-binding' ) != - 1 ) {
240
236
bindings . push ( row ) ;
@@ -251,7 +247,7 @@ functions.findRepeaterElement = function(repeater, index, binding, using, rootSe
251
247
if ( angular . getTestability ) {
252
248
matches . push . apply (
253
249
matches ,
254
- angular . getTestability ( using ) . findBindings ( rowElem , binding ) ) ;
250
+ angular . getTestability ( root ) . findBindings ( rowElem , binding ) ) ;
255
251
} else {
256
252
if ( rowElem . className . indexOf ( 'ng-binding' ) != - 1 ) {
257
253
bindings . push ( rowElem ) ;
@@ -287,8 +283,8 @@ functions.findRepeaterElement = function(repeater, index, binding, using, rootSe
287
283
*/
288
284
functions . findRepeaterColumn = function ( repeater , binding , using , rootSelector ) {
289
285
var matches = [ ] ;
290
- rootSelector = rootSelector || 'body' ;
291
- using = using || document . querySelector ( rootSelector ) ;
286
+ var root = document . querySelector ( rootSelector || 'body' ) ;
287
+ using = using || document ;
292
288
293
289
var rows = [ ] ;
294
290
var prefixes = [ 'ng-' , 'ng_' , 'data-ng-' , 'x-ng-' , 'ng\\:' ] ;
@@ -329,7 +325,7 @@ functions.findRepeaterColumn = function(repeater, binding, using, rootSelector)
329
325
if ( angular . getTestability ) {
330
326
matches . push . apply (
331
327
matches ,
332
- angular . getTestability ( using ) . findBindings ( rows [ i ] , binding ) ) ;
328
+ angular . getTestability ( root ) . findBindings ( rows [ i ] , binding ) ) ;
333
329
} else {
334
330
if ( rows [ i ] . className . indexOf ( 'ng-binding' ) != - 1 ) {
335
331
bindings . push ( rows [ i ] ) ;
@@ -345,7 +341,7 @@ functions.findRepeaterColumn = function(repeater, binding, using, rootSelector)
345
341
if ( angular . getTestability ) {
346
342
matches . push . apply (
347
343
matches ,
348
- angular . getTestability ( using ) . findBindings ( multiRows [ i ] [ j ] , binding ) ) ;
344
+ angular . getTestability ( root ) . findBindings ( multiRows [ i ] [ j ] , binding ) ) ;
349
345
} else {
350
346
var elem = multiRows [ i ] [ j ] ;
351
347
if ( elem . className . indexOf ( 'ng-binding' ) != - 1 ) {
@@ -380,11 +376,11 @@ functions.findRepeaterColumn = function(repeater, binding, using, rootSelector)
380
376
* @return {Array.<Element> } The matching elements.
381
377
*/
382
378
functions . findByModel = function ( model , using , rootSelector ) {
383
- rootSelector = rootSelector || 'body' ;
384
- using = using || document . querySelector ( rootSelector ) ;
379
+ var root = document . querySelector ( rootSelector || 'body' ) ;
380
+ using = using || document ;
385
381
386
382
if ( angular . getTestability ) {
387
- return angular . getTestability ( using ) .
383
+ return angular . getTestability ( root ) .
388
384
findModels ( using , model , true ) ;
389
385
}
390
386
var prefixes = [ 'ng-' , 'ng_' , 'data-ng-' , 'x-ng-' , 'ng\\:' ] ;
@@ -403,13 +399,11 @@ functions.findByModel = function(model, using, rootSelector) {
403
399
* @param {string } optionsDescriptor The descriptor for the option
404
400
* (i.e. fruit for fruit in fruits).
405
401
* @param {Element } using The scope of the search.
406
- * @param {string } rootSelector The selector to use for the root app element.
407
402
*
408
403
* @return {Array.<Element> } The matching elements.
409
404
*/
410
- functions . findByOptions = function ( optionsDescriptor , using , rootSelector ) {
411
- rootSelector = rootSelector || 'body' ;
412
- using = using || document . querySelector ( rootSelector ) ;
405
+ functions . findByOptions = function ( optionsDescriptor , using ) {
406
+ using = using || document ;
413
407
414
408
var prefixes = [ 'ng-' , 'ng_' , 'data-ng-' , 'x-ng-' , 'ng\\:' ] ;
415
409
for ( var p = 0 ; p < prefixes . length ; ++ p ) {
@@ -426,13 +420,11 @@ functions.findByOptions = function(optionsDescriptor, using, rootSelector) {
426
420
*
427
421
* @param {string } searchText The exact text to match.
428
422
* @param {Element } using The scope of the search.
429
- * @param {string } rootSelector The selector to use for the root app element.
430
423
*
431
424
* @return {Array.<Element> } The matching elements.
432
425
*/
433
- functions . findByButtonText = function ( searchText , using , rootSelector ) {
434
- rootSelector = rootSelector || 'body' ;
435
- using = using || document . querySelector ( rootSelector ) ;
426
+ functions . findByButtonText = function ( searchText , using ) {
427
+ using = using || document ;
436
428
437
429
var elements = using . querySelectorAll ( 'button, input[type="button"], input[type="submit"]' ) ;
438
430
var matches = [ ] ;
@@ -457,13 +449,11 @@ functions.findByButtonText = function(searchText, using, rootSelector) {
457
449
*
458
450
* @param {string } searchText The exact text to match.
459
451
* @param {Element } using The scope of the search.
460
- * @param {string } rootSelector The selector to use for the root app element.
461
452
*
462
453
* @return {Array.<Element> } The matching elements.
463
454
*/
464
- functions . findByPartialButtonText = function ( searchText , using , rootSelector ) {
465
- rootSelector = rootSelector || 'body' ;
466
- using = using || document . querySelector ( rootSelector ) ;
455
+ functions . findByPartialButtonText = function ( searchText , using ) {
456
+ using = using || document ;
467
457
468
458
var elements = using . querySelectorAll ( 'button, input[type="button"], input[type="submit"]' ) ;
469
459
var matches = [ ] ;
@@ -489,13 +479,11 @@ functions.findByPartialButtonText = function(searchText, using, rootSelector) {
489
479
* @param {string } cssSelector The css selector to match.
490
480
* @param {string } searchText The exact text to match.
491
481
* @param {Element } using The scope of the search.
492
- * @param {string } rootSelector The selector to use for the root app element.
493
482
*
494
483
* @return {Array.<Element> } An array of matching elements.
495
484
*/
496
- functions . findByCssContainingText = function ( cssSelector , searchText , using , rootSelector ) {
497
- rootSelector = rootSelector || 'body' ;
498
- using = using || document . querySelector ( rootSelector ) ;
485
+ functions . findByCssContainingText = function ( cssSelector , searchText , using ) {
486
+ using = using || document ;
499
487
500
488
var elements = using . querySelectorAll ( cssSelector ) ;
501
489
var matches = [ ] ;
@@ -629,4 +617,4 @@ for (var fnName in functions) {
629
617
}
630
618
631
619
exports . installInBrowser = ( util . format (
632
- 'window.clientSideScripts = {%s};' , scriptsList . join ( ', ' ) ) ) ;
620
+ 'window.clientSideScripts = {%s};' , scriptsList . join ( ', ' ) ) ) ;
0 commit comments