aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/compileSpec.js
diff options
context:
space:
mode:
authorVojta Jina2012-09-13 02:40:00 -0700
committerVojta Jina2012-09-20 18:32:01 -0700
commit8db47ca7d4303e3e45a838219a1f6e9be8770ed4 (patch)
tree41a8a4ec95c061001ea4c9f928f251d0d80bebd6 /test/ng/compileSpec.js
parentbcaa3bb3739c3b964750c49b216bf34bb0d8f3f6 (diff)
downloadangular.js-8db47ca7d4303e3e45a838219a1f6e9be8770ed4.tar.bz2
fix($compile): reference local in isolate scope
This was really corner case: Watcher needs to return changed value, to notify that model might have changed and one more $digest cycle needs to be performed. The watcher, that takes care of reference binding into an isolate scope ("="), did not return changed value, if the change was from the isolate scope to the parent. If any other watcher returned change, it worked fine, as this change caused re-digest. Closes #1272
Diffstat (limited to 'test/ng/compileSpec.js')
-rw-r--r--test/ng/compileSpec.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index 3d6144ac..b5e4c450 100644
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -1709,6 +1709,7 @@ describe('$compile', function() {
attrAlias: '@attr',
ref: '=',
refAlias: '= ref',
+ reference: '=',
expr: '&',
exprAlias: '&expr'
},
@@ -1830,6 +1831,24 @@ describe('$compile', function() {
$rootScope.$apply();
expect(componentScope.ref).toBe('hello misko');
}));
+
+ // regression
+ it('should stabilize model', inject(function() {
+ compile('<div><span my-component reference="name">');
+
+ var lastRefValueInParent;
+ $rootScope.$watch('name', function(ref) {
+ lastRefValueInParent = ref;
+ });
+
+ $rootScope.name = 'aaa';
+ $rootScope.$apply();
+
+ componentScope.reference = 'new';
+ $rootScope.$apply();
+
+ expect(lastRefValueInParent).toBe('new');
+ }));
});