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

fix($parse): Handle one-time to null #7787

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ng/parse.js
Original file line number Diff line number Diff line change
@@ -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);
}
});
10 changes: 10 additions & 0 deletions test/ng/parseSpec.js
Original file line number Diff line number Diff line change
@@ -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);
}));

});