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

fix($parse): stateful interceptors override an undefined expression #9825

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ function $ParseProvider() {
var result = interceptorFn(value, scope, locals);
// we only return the interceptor's result if the
// initial value is defined (for bind-once)
return isDefined(value) ? result : value;
return isDefined(value) || interceptorFn.$stateful ? result : value;
};

// Propagate $$watchDelegates other then inputsWatchDelegate
Expand Down
3 changes: 3 additions & 0 deletions src/ng/rootScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@ function $RootScopeProvider(){
newValue = _value;
var newLength, key, bothNaN, newItem, oldItem;

// If the new value is undefined, then return undefined as the watch may be a one-time watch
if (isUndefined(newValue)) return;

if (!isObject(newValue)) { // if primitive
if (oldValue !== newValue) {
oldValue = newValue;
Expand Down
25 changes: 25 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3354,6 +3354,31 @@ describe('$compile', function() {
});
});

it('should continue with a digets cycle when there is a two-way binding from the child to the parent', function() {
module(function() {
directive('hello', function() {
return {
restrict: 'E',
scope: { greeting: '=' },
template: '<button ng-click="setGreeting()">Say hi!</button>',
link: function(scope) {
scope.setGreeting = function() { scope.greeting = 'Hello!'; };
}
};
});
});

inject(function($rootScope) {
compile('<div>' +
'<p>{{greeting}}</p>' +
'<div><hello greeting="greeting"></hello></div>' +
'</div>');
$rootScope.$digest();
browserTrigger(element.find('button'), 'click');
expect(element.find('p').text()).toBe('Hello!');
});
});

});


Expand Down