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

Commit 4473b81

Browse files
lgalfasopetebacondarwin
authored andcommitted
fix($parse): handle interceptors with undefined expressions
When calling `$parse` with `undefined` as the expression and with an interceptor, then when the function is evaluated, then call the interceptor Closes: #13367 Closes: #13373
1 parent 98528be commit 4473b81

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/ng/parse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@ function $ParseProvider() {
17751775
return addInterceptor(exp, interceptorFn);
17761776

17771777
default:
1778-
return noop;
1778+
return addInterceptor(noop, interceptorFn);
17791779
}
17801780
};
17811781

test/ng/parseSpec.js

+11
Original file line numberDiff line numberDiff line change
@@ -3165,6 +3165,17 @@ describe('parser', function() {
31653165
expect(called).toBe(true);
31663166
}));
31673167

3168+
it('should invoke interceptors when the expression is `undefined`', inject(function($parse) {
3169+
var called = false;
3170+
function interceptor(v) {
3171+
called = true;
3172+
return v;
3173+
}
3174+
scope.$watch($parse(undefined, interceptor));
3175+
scope.$digest();
3176+
expect(called).toBe(true);
3177+
}));
3178+
31683179
it('should treat filters with constant input as constants', inject(function($parse) {
31693180
var filterCalls = 0;
31703181
$filterProvider.register('foo', valueFn(function(input) {

0 commit comments

Comments
 (0)