Skip to content
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

chore(Common): update the Common.now #55

Closed
wants to merge 5 commits into from
Closed

chore(Common): update the Common.now #55

wants to merge 5 commits into from

Conversation

xballoy
Copy link

@xballoy xballoy commented Dec 29, 2014

On IE9, perf.now doesn't exists and it throw an error. I updated the
function to mach with the gist

On IE9, perf.now doesn't exists and it throw an error. I updated the
function to mach with the gist
performance.msNow ||
performance.oNow ||
performance.mozNow ||
function() { return new Date().getTime(); };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should rewrite this line to simply be a reference to Date.now. It outperforms creating a new Date instance and it makes the code cleaner.

Date.now is supported by all ECMAScript 5 browsers (IE 9+).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is migrated to Date.now then it should be compatibility checked as well and Date.getTime() should still be a fallback. Not all clients are capable of supporting IE9+; we use Matter.js on IE6, for instance.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case yes, you could add it as a check before defaulting to new Date().getTime()

@liabru liabru closed this in 8555c0c May 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants