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 interceptors with undefined expressions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lgalfaso authored and petebacondarwin committed Nov 25, 2015
1 parent da11c1b commit 7bb2414
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/parse.js
Expand Up @@ -1775,7 +1775,7 @@ function $ParseProvider() {
return addInterceptor(exp, interceptorFn);

default:
return noop;
return addInterceptor(noop, interceptorFn);
}
};

Expand Down
11 changes: 11 additions & 0 deletions test/ng/parseSpec.js
Expand Up @@ -3165,6 +3165,17 @@ describe('parser', function() {
expect(called).toBe(true);
}));

it('should invoke interceptors when the expression is `undefined`', inject(function($parse) {
var called = false;
function interceptor(v) {
called = true;
return v;
}
scope.$watch($parse(undefined, interceptor));
scope.$digest();
expect(called).toBe(true);
}));

it('should treat filters with constant input as constants', inject(function($parse) {
var filterCalls = 0;
$filterProvider.register('foo', valueFn(function(input) {
Expand Down

0 comments on commit 7bb2414

Please sign in to comment.