@@ -7262,6 +7262,104 @@ describe('$compile', function() {
7262
7262
} ) ;
7263
7263
7264
7264
7265
+ describe ( 'multi-slot transclude' , function ( ) {
7266
+ it ( 'should only include elements without `ng-transclude-slot` attribute in default transclusion function' , function ( ) {
7267
+ module ( function ( ) {
7268
+ directive ( 'trans' , function ( ) {
7269
+ return {
7270
+ transclude : true ,
7271
+ template : '<div ng-transclude></div>'
7272
+ } ;
7273
+ } ) ;
7274
+ } ) ;
7275
+ inject ( function ( $rootScope , $compile ) {
7276
+ element = $compile (
7277
+ '<div trans>' +
7278
+ '<span>stuart</span>' +
7279
+ '<span>bob</span>' +
7280
+ '<span ng-transclude-slot="boss">gru</span>' +
7281
+ '<span>kevin</span>' +
7282
+ '</div>' ) ( $rootScope ) ;
7283
+ $rootScope . $apply ( ) ;
7284
+ expect ( element . text ( ) ) . toEqual ( 'stuartbobkevin' ) ;
7285
+ } ) ;
7286
+ } ) ;
7287
+
7288
+ it ( 'should transclude elements to an `ng-transclude` with a matching `ng-transclude-slot`' , function ( ) {
7289
+ module ( function ( ) {
7290
+ directive ( 'trans' , function ( ) {
7291
+ return {
7292
+ transclude : true ,
7293
+ template :
7294
+ '<div class="boss" ng-transclude="boss"></div>' +
7295
+ '<div class="minion" ng-transclude="minion"></div>' +
7296
+ '<div class="other" ng-transclude></div>'
7297
+ } ;
7298
+ } ) ;
7299
+ } ) ;
7300
+ inject ( function ( $rootScope , $compile ) {
7301
+ element = $compile (
7302
+ '<div trans>' +
7303
+ '<span ng-transclude-slot="minion">stuart</span>' +
7304
+ '<span>dorothy</span>' +
7305
+ '<span ng-transclude-slot="boss">gru</span>' +
7306
+ '<span ng-transclude-slot="minion">kevin</span>' +
7307
+ '</div>' ) ( $rootScope ) ;
7308
+ $rootScope . $apply ( ) ;
7309
+ expect ( element . children ( ) . eq ( 0 ) . text ( ) ) . toEqual ( 'gru' ) ;
7310
+ expect ( element . children ( ) . eq ( 1 ) . text ( ) ) . toEqual ( 'stuartkevin' ) ;
7311
+ expect ( element . children ( ) . eq ( 2 ) . text ( ) ) . toEqual ( 'dorothy' ) ;
7312
+ } ) ;
7313
+ } ) ;
7314
+
7315
+ it ( 'should provide the elements marked with `ng-transclude-slot` as additional transclude functions on the $$slots property' , function ( ) {
7316
+ var capturedTranscludeFn ;
7317
+ module ( function ( ) {
7318
+ directive ( 'trans' , function ( ) {
7319
+ return {
7320
+ transclude : true ,
7321
+ link : function ( scope , element , attrs , controller , transclude ) {
7322
+ capturedTranscludeFn = transclude ;
7323
+ }
7324
+ } ;
7325
+ } ) ;
7326
+ } ) ;
7327
+ inject ( function ( $rootScope , $compile , log ) {
7328
+ element = $compile (
7329
+ '<div trans>' +
7330
+ ' <span ng-transclude-slot="minion">stuart</span>' +
7331
+ ' <span ng-transclude-slot="minion">bob</span>' +
7332
+ ' <span>dorothy</span>' +
7333
+ ' <span ng-transclude-slot="boss">gru</span>' +
7334
+ '</div>' ) ( $rootScope ) ;
7335
+ $rootScope . $apply ( ) ;
7336
+
7337
+ var minionTranscludeFn = capturedTranscludeFn . $$boundTransclude . $$slots [ 'minion' ] ;
7338
+ var minions = minionTranscludeFn ( ) ;
7339
+ expect ( minions [ 0 ] . outerHTML ) . toEqual ( '<span ng-transclude-slot="minion" class="ng-scope">stuart</span>' ) ;
7340
+ expect ( minions [ 1 ] . outerHTML ) . toEqual ( '<span ng-transclude-slot="minion" class="ng-scope">bob</span>' ) ;
7341
+
7342
+ var scope = element . scope ( ) ;
7343
+
7344
+ var minionScope = jqLite ( minions [ 0 ] ) . scope ( ) ;
7345
+ expect ( minionScope . $parent ) . toBe ( scope ) ;
7346
+
7347
+ var bossTranscludeFn = capturedTranscludeFn . $$boundTransclude . $$slots [ 'boss' ] ;
7348
+ var boss = bossTranscludeFn ( ) ;
7349
+ expect ( boss [ 0 ] . outerHTML ) . toEqual ( '<span ng-transclude-slot="boss" class="ng-scope">gru</span>' ) ;
7350
+
7351
+ var bossScope = jqLite ( boss [ 0 ] ) . scope ( ) ;
7352
+ expect ( bossScope . $parent ) . toBe ( scope ) ;
7353
+
7354
+ expect ( bossScope ) . not . toBe ( minionScope ) ;
7355
+
7356
+ dealoc ( boss ) ;
7357
+ dealoc ( minions ) ;
7358
+ } ) ;
7359
+ } ) ;
7360
+ } ) ;
7361
+
7362
+
7265
7363
describe ( 'img[src] sanitization' , function ( ) {
7266
7364
7267
7365
it ( 'should NOT require trusted values for img src' , inject ( function ( $rootScope , $compile , $sce ) {
0 commit comments