@@ -7039,6 +7039,104 @@ describe('$compile', function() {
7039
7039
} ) ;
7040
7040
7041
7041
7042
+ describe ( 'multi-slot transclude' , function ( ) {
7043
+ it ( 'should only include elements without `ng-transclude-slot` attribute in default transclusion function' , function ( ) {
7044
+ module ( function ( ) {
7045
+ directive ( 'trans' , function ( ) {
7046
+ return {
7047
+ transclude : true ,
7048
+ template : '<div ng-transclude></div>'
7049
+ } ;
7050
+ } ) ;
7051
+ } ) ;
7052
+ inject ( function ( $rootScope , $compile ) {
7053
+ element = $compile (
7054
+ '<div trans>' +
7055
+ '<span>stuart</span>' +
7056
+ '<span>bob</span>' +
7057
+ '<span ng-transclude-slot="boss">gru</span>' +
7058
+ '<span>kevin</span>' +
7059
+ '</div>' ) ( $rootScope ) ;
7060
+ $rootScope . $apply ( ) ;
7061
+ expect ( element . text ( ) ) . toEqual ( 'stuartbobkevin' ) ;
7062
+ } ) ;
7063
+ } ) ;
7064
+
7065
+ it ( 'should transclude elements to an `ng-transclude` with a matching `ng-transclude-slot`' , function ( ) {
7066
+ module ( function ( ) {
7067
+ directive ( 'trans' , function ( ) {
7068
+ return {
7069
+ transclude : true ,
7070
+ template :
7071
+ '<div class="boss" ng-transclude="boss"></div>' +
7072
+ '<div class="minion" ng-transclude="minion"></div>' +
7073
+ '<div class="other" ng-transclude></div>'
7074
+ } ;
7075
+ } ) ;
7076
+ } ) ;
7077
+ inject ( function ( $rootScope , $compile ) {
7078
+ element = $compile (
7079
+ '<div trans>' +
7080
+ '<span ng-transclude-slot="minion">stuart</span>' +
7081
+ '<span>dorothy</span>' +
7082
+ '<span ng-transclude-slot="boss">gru</span>' +
7083
+ '<span ng-transclude-slot="minion">kevin</span>' +
7084
+ '</div>' ) ( $rootScope ) ;
7085
+ $rootScope . $apply ( ) ;
7086
+ expect ( element . children ( ) . eq ( 0 ) . text ( ) ) . toEqual ( 'gru' ) ;
7087
+ expect ( element . children ( ) . eq ( 1 ) . text ( ) ) . toEqual ( 'stuartkevin' ) ;
7088
+ expect ( element . children ( ) . eq ( 2 ) . text ( ) ) . toEqual ( 'dorothy' ) ;
7089
+ } ) ;
7090
+ } ) ;
7091
+
7092
+ it ( 'should provide the elements marked with `ng-transclude-slot` as additional transclude functions on the $$slots property' , function ( ) {
7093
+ var capturedTranscludeFn ;
7094
+ module ( function ( ) {
7095
+ directive ( 'trans' , function ( ) {
7096
+ return {
7097
+ transclude : true ,
7098
+ link : function ( scope , element , attrs , controller , transclude ) {
7099
+ capturedTranscludeFn = transclude ;
7100
+ }
7101
+ } ;
7102
+ } ) ;
7103
+ } ) ;
7104
+ inject ( function ( $rootScope , $compile , log ) {
7105
+ element = $compile (
7106
+ '<div trans>' +
7107
+ ' <span ng-transclude-slot="minion">stuart</span>' +
7108
+ ' <span ng-transclude-slot="minion">bob</span>' +
7109
+ ' <span>dorothy</span>' +
7110
+ ' <span ng-transclude-slot="boss">gru</span>' +
7111
+ '</div>' ) ( $rootScope ) ;
7112
+ $rootScope . $apply ( ) ;
7113
+
7114
+ var minionTranscludeFn = capturedTranscludeFn . $$boundTransclude . $$slots [ 'minion' ] ;
7115
+ var minions = minionTranscludeFn ( ) ;
7116
+ expect ( minions [ 0 ] . outerHTML ) . toEqual ( '<span ng-transclude-slot="minion" class="ng-scope">stuart</span>' ) ;
7117
+ expect ( minions [ 1 ] . outerHTML ) . toEqual ( '<span ng-transclude-slot="minion" class="ng-scope">bob</span>' ) ;
7118
+
7119
+ var scope = element . scope ( ) ;
7120
+
7121
+ var minionScope = jqLite ( minions [ 0 ] ) . scope ( ) ;
7122
+ expect ( minionScope . $parent ) . toBe ( scope ) ;
7123
+
7124
+ var bossTranscludeFn = capturedTranscludeFn . $$boundTransclude . $$slots [ 'boss' ] ;
7125
+ var boss = bossTranscludeFn ( ) ;
7126
+ expect ( boss [ 0 ] . outerHTML ) . toEqual ( '<span ng-transclude-slot="boss" class="ng-scope">gru</span>' ) ;
7127
+
7128
+ var bossScope = jqLite ( boss [ 0 ] ) . scope ( ) ;
7129
+ expect ( bossScope . $parent ) . toBe ( scope ) ;
7130
+
7131
+ expect ( bossScope ) . not . toBe ( minionScope ) ;
7132
+
7133
+ dealoc ( boss ) ;
7134
+ dealoc ( minions ) ;
7135
+ } ) ;
7136
+ } ) ;
7137
+ } ) ;
7138
+
7139
+
7042
7140
describe ( 'img[src] sanitization' , function ( ) {
7043
7141
7044
7142
it ( 'should NOT require trusted values for img src' , inject ( function ( $rootScope , $compile , $sce ) {
0 commit comments