aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/compileSpec.js
diff options
context:
space:
mode:
authorDaniel Tabuenca2013-11-27 22:01:22 -0800
committerTobias Bosch2013-12-04 09:45:20 -0800
commit2d0f6ccba896fe34141d6d4f59eef6fba580c5c2 (patch)
treef5f6601b36f82005f643435696319444af7acdf4 /test/ng/compileSpec.js
parent9a81b8668a9ee13cdea305d85325efa3efdfc01e (diff)
downloadangular.js-2d0f6ccba896fe34141d6d4f59eef6fba580c5c2.tar.bz2
fix($compile): ensure isolated local watches' lastValue is always in sync
When using two-way binding with isolate scope, under some circumstances the lastValue variable captured in the parentValueWatch function can get out of sync. Specifically, if both the value in the origin scope as well as the value in the isolate scope get independently updated to the same value within one digest cycle, the lastValue is never updated. This potentially causes the watch to make the wrong decision as to which side to update on subsequent passes. This fixes things by ensuring lastValue is always set to the last seen value even if the watch's logic was short circuited because there was no difference between the values in the original and isolate scopes. Closes #5182
Diffstat (limited to 'test/ng/compileSpec.js')
-rwxr-xr-xtest/ng/compileSpec.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index 6de96f65..c017bfa6 100755
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -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';