@@ -1681,6 +1681,19 @@ describe('$compile', function() {
1681
1681
}
1682
1682
} ;
1683
1683
} ) ;
1684
+ directive ( 'stscope' + uppercase ( name ) , function ( log ) {
1685
+ return {
1686
+ scope : true ,
1687
+ restrict : 'CA' ,
1688
+ template : '<span></span>' ,
1689
+ compile : function ( ) {
1690
+ return function ( scope , element ) {
1691
+ log ( scope . $id ) ;
1692
+ expect ( element . data ( '$scope' ) ) . toBe ( scope ) ;
1693
+ } ;
1694
+ }
1695
+ } ;
1696
+ } ) ;
1684
1697
directive ( 'trscope' + uppercase ( name ) , function ( log ) {
1685
1698
return {
1686
1699
scope : true ,
@@ -1709,6 +1722,20 @@ describe('$compile', function() {
1709
1722
}
1710
1723
} ;
1711
1724
} ) ;
1725
+ directive ( 'stiscope' + uppercase ( name ) , function ( log ) {
1726
+ return {
1727
+ scope : { } ,
1728
+ restrict : 'CA' ,
1729
+ template : '<span></span>' ,
1730
+ compile : function ( ) {
1731
+ return function ( scope , element ) {
1732
+ iscope = scope ;
1733
+ log ( scope . $id ) ;
1734
+ expect ( element . data ( '$isolateScope' ) ) . toBe ( scope ) ;
1735
+ } ;
1736
+ }
1737
+ } ;
1738
+ } ) ;
1712
1739
} ) ;
1713
1740
directive ( 'log' , function ( log ) {
1714
1741
return {
@@ -1883,6 +1910,13 @@ describe('$compile', function() {
1883
1910
expect ( element . find ( 'a' ) . scope ( ) . $parent ) . toBe ( $rootScope ) ;
1884
1911
} )
1885
1912
) ;
1913
+
1914
+ it ( 'should return the new scope for children in the directive sync template' , inject (
1915
+ function ( $rootScope , $compile ) {
1916
+ element = $compile ( '<div stscope></div>' ) ( $rootScope ) ;
1917
+ expect ( element . find ( 'span' ) . scope ( ) . $parent ) . toBe ( $rootScope ) ;
1918
+ } )
1919
+ ) ;
1886
1920
} ) ;
1887
1921
1888
1922
@@ -1925,6 +1959,14 @@ describe('$compile', function() {
1925
1959
expect ( element . isolateScope ( ) ) . not . toBe ( $rootScope ) ;
1926
1960
} )
1927
1961
) ;
1962
+
1963
+ it ( 'should return the isolate scope for children in directive sync template' , inject (
1964
+ function ( $rootScope , $compile ) {
1965
+ element = $compile ( '<div stiscope></div>' ) ( $rootScope ) ;
1966
+ expect ( element . find ( 'span' ) . scope ( ) ) . toBe ( element . isolateScope ( ) ) ;
1967
+ expect ( element . isolateScope ( ) ) . not . toBe ( $rootScope ) ;
1968
+ } )
1969
+ ) ;
1928
1970
} ) ;
1929
1971
1930
1972
@@ -1954,6 +1996,17 @@ describe('$compile', function() {
1954
1996
expect ( child . scope ( ) ) . toBe ( directiveElement . isolateScope ( ) ) ;
1955
1997
} )
1956
1998
) ;
1999
+
2000
+ it ( 'should return the isolate scope for child elements in directive sync template' , inject (
2001
+ function ( $rootScope , $compile ) {
2002
+ var directiveElement , child ;
2003
+ element = $compile ( '<div><a ng-if="true" stiscope></a></div>' ) ( $rootScope ) ;
2004
+ $rootScope . $apply ( ) ;
2005
+ directiveElement = element . find ( 'a' ) ;
2006
+ child = directiveElement . find ( 'span' ) ;
2007
+ expect ( child . scope ( ) ) . toBe ( directiveElement . isolateScope ( ) ) ;
2008
+ } )
2009
+ ) ;
1957
2010
} ) ;
1958
2011
} ) ;
1959
2012
} ) ;
0 commit comments