@@ -7948,7 +7948,7 @@ ddescribe('$compile', function() {
7948
7948
} ) ;
7949
7949
7950
7950
7951
- it ( 'should provide the elements marked with matching transclude elements as additional transclude functions on the $slots property ' , function ( ) {
7951
+ it ( 'should return true from `isSlotFilled(slotName) for slots that have content in the transclusion ' , function ( ) {
7952
7952
var capturedTranscludeFn ;
7953
7953
module ( function ( ) {
7954
7954
directive ( 'minionComponent' , function ( ) {
@@ -7957,7 +7957,7 @@ ddescribe('$compile', function() {
7957
7957
scope : { } ,
7958
7958
transclude : {
7959
7959
minionSlot : 'minion' ,
7960
- bossSlot : 'boss'
7960
+ bossSlot : '? boss'
7961
7961
} ,
7962
7962
template :
7963
7963
'<div class="boss" ng-transclude="bossSlot"></div>' +
@@ -7975,59 +7975,14 @@ ddescribe('$compile', function() {
7975
7975
' <minion>stuart</minion>' +
7976
7976
' <minion>bob</minion>' +
7977
7977
' <span>dorothy</span>' +
7978
- ' <boss>gru</boss>' +
7979
7978
'</minion-component>' ) ( $rootScope ) ;
7980
7979
$rootScope . $apply ( ) ;
7981
7980
7982
- var minionTranscludeFn = capturedTranscludeFn . $slots [ 'minionSlot' ] ;
7983
- var minions = minionTranscludeFn ( ) ;
7984
- expect ( minions [ 0 ] . outerHTML ) . toEqual ( '<minion class="ng-scope">stuart</minion>' ) ;
7985
- expect ( minions [ 1 ] . outerHTML ) . toEqual ( '<minion class="ng-scope">bob</minion>' ) ;
7986
-
7987
- var scope = element . scope ( ) ;
7988
-
7989
- var minionScope = jqLite ( minions [ 0 ] ) . scope ( ) ;
7990
- expect ( minionScope . $parent ) . toBe ( scope ) ;
7991
-
7992
- var bossTranscludeFn = capturedTranscludeFn . $slots [ 'bossSlot' ] ;
7993
- var boss = bossTranscludeFn ( ) ;
7994
- expect ( boss [ 0 ] . outerHTML ) . toEqual ( '<boss class="ng-scope">gru</boss>' ) ;
7995
-
7996
- var bossScope = jqLite ( boss [ 0 ] ) . scope ( ) ;
7997
- expect ( bossScope . $parent ) . toBe ( scope ) ;
7998
-
7999
- expect ( bossScope ) . not . toBe ( minionScope ) ;
8000
-
8001
- dealoc ( boss ) ;
8002
- dealoc ( minions ) ;
8003
- } ) ;
8004
- } ) ;
7981
+ var hasMinions = capturedTranscludeFn . isSlotFilled ( 'minionSlot' ) ;
7982
+ var hasBosses = capturedTranscludeFn . isSlotFilled ( 'bossSlot' ) ;
8005
7983
8006
- it ( 'should set unfilled optional transclude slots to `null` in the $transclude.$slots property' , function ( ) {
8007
- var capturedTranscludeFn ;
8008
- module ( function ( ) {
8009
- directive ( 'minionComponent' , function ( ) {
8010
- return {
8011
- restrict : 'E' ,
8012
- scope : { } ,
8013
- transclude : {
8014
- minionSlot : 'minion' ,
8015
- bossSlot : '?boss'
8016
- } ,
8017
- link : function ( s , e , a , c , transcludeFn ) {
8018
- capturedTranscludeFn = transcludeFn ;
8019
- }
8020
- } ;
8021
- } ) ;
8022
- } ) ;
8023
- inject ( function ( $rootScope , $compile ) {
8024
- element = $compile (
8025
- '<minion-component>' +
8026
- '<minion>stuart</minion>' +
8027
- '<span>dorothy</span>' +
8028
- '</minion-component>' ) ( $rootScope ) ;
8029
- expect ( capturedTranscludeFn . $slots . minionSlot ) . toEqual ( jasmine . any ( Function ) ) ;
8030
- expect ( capturedTranscludeFn . $slots . bossSlot ) . toBe ( null ) ;
7984
+ expect ( hasMinions ) . toBe ( true ) ;
7985
+ expect ( hasBosses ) . toBe ( false ) ;
8031
7986
} ) ;
8032
7987
} ) ;
8033
7988
0 commit comments