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

fix($compile): ensure isolated local watches lastValue is always in syn... #5182

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
parentSet(scope, parentValue = lastValue = isolateScope[scopeName]);
}
}
return parentValue;
return lastValue = parentValue;
});
break;

Expand Down
18 changes: 18 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2386,6 +2386,24 @@ describe('$compile', function() {
expect(componentScope.refAlias).toBe($rootScope.name);
}));

it('should not break if local and origin both change to the same value', inject(function() {
$rootScope.name = 'aaa';

compile('<div><span my-component ref="name">');

//change both sides to the same item withing the same digest cycle
componentScope.ref = 'same';
$rootScope.name = 'same';
$rootScope.$apply();

//change origin back to it's previous value
$rootScope.name = 'aaa';
$rootScope.$apply();

expect($rootScope.name).toBe('aaa');
expect(componentScope.ref).toBe('aaa');
}));

it('should complain on non assignable changes', inject(function() {
compile('<div><span my-component ref="\'hello \' + name">');
$rootScope.name = 'world';
Expand Down