File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -346,7 +346,8 @@ function $CompileProvider($provide) {
346
346
var preLinkFns = previousCompileContext . preLinkFns || [ ] ;
347
347
var postLinkFns = previousCompileContext . postLinkFns || [ ] ;
348
348
var controllers = { } ;
349
- var newScopeDirective , newIsolateScopeDirective ;
349
+ var newScopeDirective ;
350
+ var newIsolateScopeDirective = previousCompileContext . newIsolateScopeDirective ;
350
351
var templateDirective = previousCompileContext . templateDirective ;
351
352
var controllerDirectives ;
352
353
@@ -445,6 +446,7 @@ function $CompileProvider($provide) {
445
446
attrs ,
446
447
{
447
448
templateDirective : templateDirective ,
449
+ newIsolateScopeDirective : newIsolateScopeDirective ,
448
450
preLinkFns : preLinkFns ,
449
451
postLinkFns : postLinkFns
450
452
}
Original file line number Diff line number Diff line change @@ -2388,6 +2388,36 @@ describe('$compile', function() {
2388
2388
} ) ;
2389
2389
} ) ;
2390
2390
2391
+ it ( 'retains isolate scope directives from earlier' , function ( ) {
2392
+ var linkSpy = jasmine . createSpy ( ) ;
2393
+ var injector = makeInjectorWithDirectives ( {
2394
+ myDirective : function ( ) {
2395
+ return {
2396
+ scope : { val : '=myDirective' } ,
2397
+ link : linkSpy
2398
+ } ;
2399
+ } ,
2400
+ myOtherDirective : function ( ) {
2401
+ return { templateUrl : '/my_other_directive.html' } ;
2402
+ }
2403
+ } ) ;
2404
+ injector . invoke ( function ( $compile , $rootScope ) {
2405
+ var el = $ ( '<div my-directive="42" my-other-directive></div>' ) ;
2406
+
2407
+ var linkFunction = $compile ( el ) ;
2408
+ $rootScope . $apply ( ) ;
2409
+
2410
+ linkFunction ( $rootScope ) ;
2411
+
2412
+ requests [ 0 ] . respond ( 200 , { } , '<div></div>' ) ;
2413
+
2414
+ expect ( linkSpy ) . toHaveBeenCalled ( ) ;
2415
+ expect ( linkSpy . calls . first ( ) . args [ 0 ] ) . toBeDefined ( ) ;
2416
+ expect ( linkSpy . calls . first ( ) . args [ 0 ] ) . not . toBe ( $rootScope ) ;
2417
+ expect ( linkSpy . calls . first ( ) . args [ 0 ] . val ) . toBe ( 42 ) ;
2418
+ } ) ;
2419
+ } ) ;
2420
+
2391
2421
} ) ;
2392
2422
2393
2423
} ) ;
You can’t perform that action at this time.
0 commit comments