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

Commit

Permalink
fix($parse): Handle one-time to null
Browse files Browse the repository at this point in the history
Handles when a one-time binding stabilizes to `null`

Closes #7743
Closes #7787
  • Loading branch information
lgalfaso authored and rodyhaddad committed Jun 13, 2014
1 parent 398053c commit 600a41a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ng/parse.js
Expand Up @@ -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);
}
});
Expand Down
10 changes: 10 additions & 0 deletions test/ng/parseSpec.js
Expand Up @@ -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);
}));

});


Expand Down

0 comments on commit 600a41a

Please sign in to comment.