angular/angular.js — pull request #4737 by ttsiodras (2013-10-31 16:47:32+00:00)
Title: If the underlying model is a date, !== will not work for comparison

While using a custom directive that uses a Date for the underlying model, I found out that when $setViewValue is called, Angular decides on whether to call the ngChange listeners via a simple comparison:

if (this.$modelValue !== value)

Unfortunately, this doesn't work if the model is a Date - javascript doesn't properly compare two identical Date objects:

$ node
var a = new Date(0);
var b = new Date(0);
a !== b
(prints true)

So I had to add the following patch that checks whether the model is a Date or not - and if it is, it uses the "proper" way to compare Dates in javascript, namely... casting via "+".

I hope this gets accepted - I wasted quite some time tracking this, no need for anyone else to pay the same price...