mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-17 11:11:05 +00:00
fix(compile): Initialize interpolated attributes before directive linking
This commit is contained in:
parent
2ed53087d7
commit
bb8448c011
2 changed files with 4 additions and 3 deletions
|
|
@ -1037,7 +1037,7 @@ function $CompileProvider($provide) {
|
||||||
interpolateFn = $interpolate(attr[name], true);
|
interpolateFn = $interpolate(attr[name], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
attr[name] = undefined;
|
attr[name] = interpolateFn(scope);
|
||||||
($$observers[name] || ($$observers[name] = [])).$$inter = true;
|
($$observers[name] || ($$observers[name] = [])).$$inter = true;
|
||||||
(attr.$$observers && attr.$$observers[name].$$scope || scope).
|
(attr.$$observers && attr.$$observers[name].$$scope || scope).
|
||||||
$watch(interpolateFn, function interpolateFnWatchAction(value) {
|
$watch(interpolateFn, function interpolateFnWatchAction(value) {
|
||||||
|
|
|
||||||
|
|
@ -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);
|
$compile('<div some-attr="{{whatever}}" observer></div>')($rootScope);
|
||||||
expect(directiveAttrs.someAttr).toBeUndefined();
|
expect(directiveAttrs.someAttr).toBe($rootScope.whatever);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue