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

Commit

Permalink
fix(compile): Initialize interpolated attributes before directive lin…
Browse files Browse the repository at this point in the history
…king
  • Loading branch information
petebacondarwin authored and mhevery committed Feb 15, 2013
1 parent 2ed5308 commit bb8448c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ function $CompileProvider($provide) {
interpolateFn = $interpolate(attr[name], true);
}

attr[name] = undefined;
attr[name] = interpolateFn(scope);
($$observers[name] || ($$observers[name] = [])).$$inter = true;
(attr.$$observers && attr.$$observers[name].$$scope || scope).
$watch(interpolateFn, function interpolateFnWatchAction(value) {
Expand Down
5 changes: 3 additions & 2 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,9 +1381,10 @@ describe('$compile', function() {
}));


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


Expand Down

0 comments on commit bb8448c

Please sign in to comment.