File tree Expand file tree Collapse file tree 3 files changed +14
-10
lines changed
modules/angular2/src/core/testability Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -91,8 +91,9 @@ class PublicTestability implements _JsObjectProxyable {
9191
9292class GetTestability {
9393 static addToWindow (TestabilityRegistry registry) {
94- js.context['getAngularTestability' ] = _jsify ((Element elem) {
95- Testability testability = registry.findTestabilityInTree (elem);
94+ js.context['getAngularTestability' ] = _jsify ((Element elem,
95+ [bool findInAncestors = true ]) {
96+ Testability testability = registry.findTestabilityInTree (elem, findInAncestors);
9697 if (testability == null ) {
9798 throw 'Could not find testability for element.' ;
9899 }
Original file line number Diff line number Diff line change @@ -15,14 +15,15 @@ class PublicTestability {
1515
1616export class GetTestability {
1717 static addToWindow ( registry : TestabilityRegistry ) {
18- global . getAngularTestability = function ( elem : Element ) : PublicTestability {
19- var testability = registry . findTestabilityInTree ( elem ) ;
18+ global . getAngularTestability = function ( elem : Element , findInAncestors : boolean = true ) :
19+ PublicTestability {
20+ var testability = registry . findTestabilityInTree ( elem , findInAncestors ) ;
2021
21- if ( testability == null ) {
22- throw new Error ( 'Could not find testability for element.' ) ;
23- }
24- return new PublicTestability ( testability ) ;
25- } ;
22+ if ( testability == null ) {
23+ throw new Error ( 'Could not find testability for element.' ) ;
24+ }
25+ return new PublicTestability ( testability ) ;
26+ } ;
2627 global . getAllAngularTestabilities = function ( ) : List < PublicTestability > {
2728 var testabilities = registry . getAllTestabilities ( ) ;
2829 return testabilities . map ( ( testability ) => { return new PublicTestability ( testability ) ; } ) ;
Original file line number Diff line number Diff line change @@ -84,12 +84,14 @@ export class TestabilityRegistry {
8484
8585 getAllTestabilities ( ) : List < Testability > { return MapWrapper . values ( this . _applications ) ; }
8686
87- findTestabilityInTree ( elem : Node ) : Testability {
87+ findTestabilityInTree ( elem : Node , findInAncestors : boolean = true ) : Testability {
8888 if ( elem == null ) {
8989 return null ;
9090 }
9191 if ( this . _applications . has ( elem ) ) {
9292 return this . _applications . get ( elem ) ;
93+ } else if ( ! findInAncestors ) {
94+ return null ;
9395 }
9496 if ( DOM . isShadowRoot ( elem ) ) {
9597 return this . findTestabilityInTree ( DOM . getHost ( elem ) ) ;
You can’t perform that action at this time.
0 commit comments