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

Commit bb8448c

Browse files
petebacondarwinmhevery
authored andcommitted
fix(compile): Initialize interpolated attributes before directive linking
1 parent 2ed5308 commit bb8448c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/ng/compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ function $CompileProvider($provide) {
10371037
interpolateFn = $interpolate(attr[name], true);
10381038
}
10391039

1040-
attr[name] = undefined;
1040+
attr[name] = interpolateFn(scope);
10411041
($$observers[name] || ($$observers[name] = [])).$$inter = true;
10421042
(attr.$$observers && attr.$$observers[name].$$scope || scope).
10431043
$watch(interpolateFn, function interpolateFnWatchAction(value) {

test/ng/compileSpec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1381,9 +1381,10 @@ describe('$compile', function() {
13811381
}));
13821382

13831383

1384-
it('should set interpolated attrs to undefined', inject(function($rootScope, $compile) {
1384+
it('should set interpolated attrs to initial interpolation value', inject(function($rootScope, $compile) {
1385+
$rootScope.whatever = 'test value';
13851386
$compile('<div some-attr="{{whatever}}" observer></div>')($rootScope);
1386-
expect(directiveAttrs.someAttr).toBeUndefined();
1387+
expect(directiveAttrs.someAttr).toBe($rootScope.whatever);
13871388
}));
13881389

13891390

0 commit comments

Comments
 (0)