mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-11 19:08:22 +08:00
fix($parse): Handle one-time to null
Handles when a one-time binding stabilizes to `null` Closes #7743 Closes #7787
This commit is contained in:
committed by
rodyhaddad
parent
398053c563
commit
600a41a7b6
@@ -1055,7 +1055,8 @@ function $ParseProvider() {
|
||||
if (oneTimeParseFn.$$unwatch && self && self.$$postDigestQueue) {
|
||||
self.$$postDigestQueue.push(function () {
|
||||
// create a copy if the value is defined and it is not a $sce value
|
||||
if ((stable = isDefined(lastValue)) && !lastValue.$$unwrapTrustedValue) {
|
||||
if ((stable = isDefined(lastValue)) &&
|
||||
(lastValue === null || !lastValue.$$unwrapTrustedValue)) {
|
||||
lastValue = copy(lastValue, null);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1012,8 +1012,18 @@ describe('parser', function() {
|
||||
|
||||
value.baz = 'baz';
|
||||
expect(fn()).toEqual({bar: 'bar'});
|
||||
|
||||
}));
|
||||
|
||||
it('should not throw if the stable value is `null`', inject(function($parse, $rootScope) {
|
||||
var fn = $parse('::foo');
|
||||
$rootScope.$watch(fn);
|
||||
$rootScope.foo = null;
|
||||
$rootScope.$digest();
|
||||
$rootScope.foo = 'foo';
|
||||
$rootScope.$digest();
|
||||
expect(fn()).toEqual(null);
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user