-
Notifications
You must be signed in to change notification settings - Fork 22.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
D3.js >= 3.1.10 transitions break when date.js is loaded #1302
Comments
As far as I can tell, Date.js does not redefine var s = document.createElement("script");
s.setAttribute("src", "//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js");
document.head.appendChild(s);
Date.now(); Also, if you examine
Even if Date.js did redefine <script src="date.js"></script>
<script>Date.now = function() { return +new Date; };</script> |
Mike, Are you sure that you don't want me to create a pull request which adds a check that throws an exception if Date.now returns the wrong value, just to let people know something is wrong and save them some pain? |
Glad I could help. And although I appreciate your offer to help, I don’t want to burden D3 with workarounds for libraries that break standards; that would add complexity and bytes. |
This is related and thank you all for the work on this already. Not only does the cdn not have Date.now but the date of the build is totally different with no version bump. |
If anyone cares the May 2008 build on the cdn is from the trunk. It is not labeled as a release. |
I'm using http://www.datejs.com/ on the same page as d3, which break d3 transitions.
Date.js modifies the Date object in such way that's it's incompatible with the contract set by Javascript 1.5. In Date.js now() returns a Date object whereas the new, native method returns a numeric timestamp. From d3 3.1.10 Date.now is used in the internal "d3_timer_mark" function, which raised the issue. The now() method overridden by date.js is used by d3, and the symptom is that transitions fail silently in d3.
Although this should be resolved in Date.js (never will, not updated since release 2007), I do think something should be done in d3 as well. Date.js has a couple of million downloads on google code, so other people will cluelessly experience this issue. These are my two suggestions on how to move forward:
Here's a example of how d3 behaves when date.js is loaded (fails silently):
http://bl.ocks.org/baversjo/ffe2d5081a787a4090eb
And when it's not (works!):
http://bl.ocks.org/mbostock/b4e46124258d1b75accb
The text was updated successfully, but these errors were encountered: