plaa/TimeShift-js

applying native methods on TimeShift.Date instances throws exception

Closed this issue · 3 comments

If a native date function is applied with a mock one, Chrome will throw "this is not a Date object" exception (I'm sure other browsers won't tolerate this either).

This can be problematic when for example a third party library holds a reference to the native date prototype and call them with passed in TimeShift Dates.

I'm not aware that there is any way of fixing this but it should be mentioned in the Ceveats section imho.

plaa commented

Shouldn't it be possible to work around this by initializing TimeShift-js before loading the library? (Of course this may be problematic in some cases.)

It is indeed, but that might not always be an option (and I guess in most cases the exception above comes as a surprise and hard to decipher).

plaa commented

Added note in the caveats.