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
@mdvorak

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.

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