Skip to content

Commit 903d1c0

Browse files
committed
Preserving The Isolate Scope Directive
1 parent 81c8789 commit 903d1c0

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/compile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ function $CompileProvider($provide) {
346346
var preLinkFns = previousCompileContext.preLinkFns || [];
347347
var postLinkFns = previousCompileContext.postLinkFns || [];
348348
var controllers = {};
349-
var newScopeDirective, newIsolateScopeDirective;
349+
var newScopeDirective;
350+
var newIsolateScopeDirective = previousCompileContext.newIsolateScopeDirective;
350351
var templateDirective = previousCompileContext.templateDirective;
351352
var controllerDirectives;
352353

@@ -445,6 +446,7 @@ function $CompileProvider($provide) {
445446
attrs,
446447
{
447448
templateDirective: templateDirective,
449+
newIsolateScopeDirective: newIsolateScopeDirective,
448450
preLinkFns: preLinkFns,
449451
postLinkFns: postLinkFns
450452
}

test/compile_spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,6 +2388,36 @@ describe('$compile', function() {
23882388
});
23892389
});
23902390

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+
23912421
});
23922422

23932423
});

0 commit comments

Comments
 (0)