Skip to content
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.

max or min causes input type=date to fire $viewChangeListeners during every validation #10125

Closed

Description

@mdvorak

Angular 1.3.3
Problem is that in general, objects are compared using !==, which does not work as expected for Date objects. Culprit is this function

function writeToModelIfNeeded() {
  if (ctrl.$modelValue !== prevModelValue) {
    ctrl.$$writeModelToScope();
  }
}

for this to work, it would have to be same instance of the Date. For date input types, this comparsion should be smarter and compare Date.getTime() insted.
This also causes to fire changed event during initialization when max or min are used (since they call $validate).

Sample: http://plnkr.co/edit/vXNfLHkF9wbhjJRueblL?p=preview

In the sample, you can check that in writeToModelIfNeeded during init are both prevModelValue and $modelValue same, just not the same instance.

Activity

  1. mdvorak commented on Nov 19, 2014

    @mdvorak
    Author

    This may be related to #9913, but I did not test it.

  2. Narretz commented on Nov 19, 2014

    @Narretz
    Contributor

    It is indeed the same issue. It will be fixed in 1.3.4, you can see a preview here: http://plnkr.co/edit/YpCpE1NQM83sXo8vY18d?p=preview

  3. mdvorak commented on Nov 20, 2014

    @mdvorak
    Author

    Ah, thats great news, next time I'll test against master as well :) Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions