mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
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
This commit is contained in:
parent
ccd52abf5d
commit
cf2c49ed7f
2 changed files with 20 additions and 1 deletions
|
|
@ -747,7 +747,7 @@ function $CompileProvider($provide) {
|
|||
lastValue = scope[scopeName] = parentValue;
|
||||
} else {
|
||||
// if the parent can be assigned then do so
|
||||
parentSet(parentScope, lastValue = scope[scopeName]);
|
||||
parentSet(parentScope, parentValue = lastValue = scope[scopeName]);
|
||||
}
|
||||
}
|
||||
return parentValue;
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue