Skip to content
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
jbedard opened this issue May 4, 2017 · 0 comments

Comments

@jbedard
Copy link
Collaborator

jbedard commented May 4, 2017

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

@jbedard jbedard self-assigned this May 4, 2017
@Narretz Narretz added this to the 1.6.x milestone May 9, 2017
jbedard added a commit to jbedard/angular.js that referenced this issue May 12, 2017
jbedard added a commit to jbedard/angular.js that referenced this issue May 12, 2017
jbedard added a commit to jbedard/angular.js that referenced this issue May 18, 2017
jbedard added a commit to jbedard/angular.js that referenced this issue May 18, 2017
jbedard added a commit to jbedard/angular.js that referenced this issue May 24, 2017
jbedard added a commit to jbedard/angular.js that referenced this issue May 25, 2017
jbedard added a commit that referenced this issue May 25, 2017
jbedard added a commit that referenced this issue May 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants