This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Filters are not re-evaluated with non-simple input when present in an object/array literal #15964
Closed
Description
This is something not handled correctly by 25f008f which started shallow-watching the inputs to object/array literals (even if those inputs are non-simple). But in some cases those inputs might go through filters which change output based on non-shallow state.
Before 25f008f such expressions would throw an infdig error so this is not a regression. However once ng-class started using this it caused one version of #15905 (the other version would be nested objects, this is the objects-passed-to-filters version).
Here is a test showing this problem (can be pasted into parserSpec.js):
it('should reevaluate filters in literals with non-primitive', inject(function($parse) {
var filterCalls = 0;
$filterProvider.register('xy', valueFn(function(input) {
filterCalls++;
return input.x + input.y
}));
var watchCalls = 0;
scope.$watch("{key: (value | xy)}", function() {
watchCalls++;
});
scope.$apply("value = {x: 1, y: 1}");
expect(filterCalls).toBe(1);
expect(watchCalls).toBe(1);
scope.$apply();
expect(filterCalls).toBe(2);
expect(watchCalls).toBe(1);
scope.$apply("value.x = 2");
expect(filterCalls).toBe(3);
expect(watchCalls).toBe(2);
}));
Note: interceptors and filters need the same fix in order to solve #15905