A ramification of this is that d3.interpolate no longer supports interpolating dates: dates are treated as generic objects, and since they do not have any enumerable properties, the resulting interpolator returns the empty object.
I see two non-exclusive options:
After step 5, check if b is a date using instanceof Date, and if so, use a new d3.interpolateDate instead of d3.interpolateObject.
After step 5, check if b is coercible to a number using !isNaN(b), and if so, use d3.interpolateNumber instead of d3.interpolateObject.
Note that if we only do the second option, then the resulting interpolator will return numbers rather than Date instances. In practice, this is typically fine because all methods in D3 that accept dates should create a Date instance from a number if they are given a number. However, it might be cleaner to handle dates specially, since the Date is a first-class type in JavaScript.
Related comment: d3.interpolateDate should probably reuse the returned date instance, for performance, like d3.interpolateObject and d3.interpolateArray do.
Related d3/d3#2878. The old behavior of d3.interpolate was:
Note the “and not coercible to a number” rule in step 4. The new algorithm does not treat objects that are coercible to numbers specially:
A ramification of this is that d3.interpolate no longer supports interpolating dates: dates are treated as generic objects, and since they do not have any enumerable properties, the resulting interpolator returns the empty object.
I see two non-exclusive options:
instanceof Date
, and if so, use a new d3.interpolateDate instead of d3.interpolateObject.!isNaN(b)
, and if so, use d3.interpolateNumber instead of d3.interpolateObject.Note that if we only do the second option, then the resulting interpolator will return numbers rather than Date instances. In practice, this is typically fine because all methods in D3 that accept dates should create a Date instance from a number if they are given a number. However, it might be cleaner to handle dates specially, since the Date is a first-class type in JavaScript.