Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 92ca7ef

Browse files
Enrique ParedesIgorMinar
Enrique Paredes
authored andcommitted
fix($compile): rename $compileNote to compileNode
Directives was observing different instances of Attributes than the one that interpolation was registered with because we failed to realize that the compile node and link node were the same (one of them was a wrapper rather than raw node) Closes #1941
1 parent 7090924 commit 92ca7ef

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/ng/compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ function $CompileProvider($provide) {
938938
}
939939

940940
directives.unshift(derivedSyncDirective);
941-
afterTemplateNodeLinkFn = applyDirectivesToNode(directives, $compileNode, tAttrs, childTranscludeFn);
941+
afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs, childTranscludeFn);
942942
afterTemplateChildLinkFn = compileNodes($compileNode.contents(), childTranscludeFn);
943943

944944

test/ng/compileSpec.js

+19
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,25 @@ describe('$compile', function() {
15381538
expect(element.text()).toEqual('WORKS');
15391539
});
15401540
});
1541+
1542+
it('should support $observe inside link function on directive object', function() {
1543+
module(function() {
1544+
directive('testLink', valueFn({
1545+
templateUrl: 'test-link.html',
1546+
link: function(scope, element, attrs) {
1547+
attrs.$observe( 'testLink', function ( val ) {
1548+
scope.testAttr = val;
1549+
});
1550+
}
1551+
}));
1552+
});
1553+
inject(function($compile, $rootScope, $templateCache) {
1554+
$templateCache.put('test-link.html', '{{testAttr}}' );
1555+
element = $compile('<div test-link="{{1+2}}"></div>')($rootScope);
1556+
$rootScope.$apply();
1557+
expect(element.text()).toBe('3');
1558+
});
1559+
});
15411560
});
15421561

15431562

0 commit comments

Comments
 (0)