@@ -1797,6 +1797,19 @@ describe('$compile', function() {
1797
1797
}
1798
1798
} ;
1799
1799
} ) ;
1800
+ directive ( 'stscope' + uppercase ( name ) , function ( log ) {
1801
+ return {
1802
+ scope : true ,
1803
+ restrict : 'CA' ,
1804
+ template : '<span></span>' ,
1805
+ compile : function ( ) {
1806
+ return function ( scope , element ) {
1807
+ log ( scope . $id ) ;
1808
+ expect ( element . data ( '$scope' ) ) . toBe ( scope ) ;
1809
+ } ;
1810
+ }
1811
+ } ;
1812
+ } ) ;
1800
1813
directive ( 'trscope' + uppercase ( name ) , function ( log ) {
1801
1814
return {
1802
1815
scope : true ,
@@ -1825,6 +1838,20 @@ describe('$compile', function() {
1825
1838
}
1826
1839
} ;
1827
1840
} ) ;
1841
+ directive ( 'stiscope' + uppercase ( name ) , function ( log ) {
1842
+ return {
1843
+ scope : { } ,
1844
+ restrict : 'CA' ,
1845
+ template : '<span></span>' ,
1846
+ compile : function ( ) {
1847
+ return function ( scope , element ) {
1848
+ iscope = scope ;
1849
+ log ( scope . $id ) ;
1850
+ expect ( element . data ( '$isolateScope' ) ) . toBe ( scope ) ;
1851
+ } ;
1852
+ }
1853
+ } ;
1854
+ } ) ;
1828
1855
} ) ;
1829
1856
directive ( 'log' , function ( log ) {
1830
1857
return {
@@ -1999,6 +2026,13 @@ describe('$compile', function() {
1999
2026
expect ( element . find ( 'a' ) . scope ( ) . $parent ) . toBe ( $rootScope ) ;
2000
2027
} )
2001
2028
) ;
2029
+
2030
+ it ( 'should return the new scope for children in the directive sync template' , inject (
2031
+ function ( $rootScope , $compile ) {
2032
+ element = $compile ( '<div stscope></div>' ) ( $rootScope ) ;
2033
+ expect ( element . find ( 'span' ) . scope ( ) . $parent ) . toBe ( $rootScope ) ;
2034
+ } )
2035
+ ) ;
2002
2036
} ) ;
2003
2037
2004
2038
@@ -2041,6 +2075,14 @@ describe('$compile', function() {
2041
2075
expect ( element . isolateScope ( ) ) . not . toBe ( $rootScope ) ;
2042
2076
} )
2043
2077
) ;
2078
+
2079
+ it ( 'should return the isolate scope for children in directive sync template' , inject (
2080
+ function ( $rootScope , $compile ) {
2081
+ element = $compile ( '<div stiscope></div>' ) ( $rootScope ) ;
2082
+ expect ( element . find ( 'span' ) . scope ( ) ) . toBe ( element . isolateScope ( ) ) ;
2083
+ expect ( element . isolateScope ( ) ) . not . toBe ( $rootScope ) ;
2084
+ } )
2085
+ ) ;
2044
2086
} ) ;
2045
2087
2046
2088
@@ -2070,6 +2112,17 @@ describe('$compile', function() {
2070
2112
expect ( child . scope ( ) ) . toBe ( directiveElement . isolateScope ( ) ) ;
2071
2113
} )
2072
2114
) ;
2115
+
2116
+ it ( 'should return the isolate scope for child elements in directive sync template' , inject (
2117
+ function ( $rootScope , $compile ) {
2118
+ var directiveElement , child ;
2119
+ element = $compile ( '<div><a ng-if="true" stiscope></a></div>' ) ( $rootScope ) ;
2120
+ $rootScope . $apply ( ) ;
2121
+ directiveElement = element . find ( 'a' ) ;
2122
+ child = directiveElement . find ( 'span' ) ;
2123
+ expect ( child . scope ( ) ) . toBe ( directiveElement . isolateScope ( ) ) ;
2124
+ } )
2125
+ ) ;
2073
2126
} ) ;
2074
2127
} ) ;
2075
2128
} ) ;
0 commit comments