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

Can't format a moment in IE10 "Unable to get property '1' of undefined or null reference" #69

Closed
christheyounger opened this issue Apr 11, 2017 · 7 comments

Comments

@christheyounger
Copy link

Open the console, run:
moment.duration(928515).format();
Safari Says:
"15:29"
IE10 Says:
"Unable to get property '1' of undefined or null reference"

@emielvanliere
Copy link

Workaround: moment.duration.fn.format.defaults.decimalSeparator = ':';

jsmreese pushed a commit that referenced this issue Nov 30, 2017
- Added `useGrouping` and `userLocale` options
- Removed `decimalSeparator` option
- Fixes #70, #69, #26
@jsmreese
Copy link
Owner

Closing this. FIxed in 8983903.
This issue was fixed by removing the decimalSeparator option and the defaultDecimalSeparator function that caused the issue. Decimal separators are now rendered via toLocaleString.

@christheyounger
Copy link
Author

Yeah, but now when I run moment.duration(928515).format()
I get "15.00:29.00"
That's a hell of a format

@jsmreese
Copy link
Owner

jsmreese commented Dec 4, 2017

You must have something changed in the default settings?
With a test page that was loaded from close to the head of master on github, I see something reasonable...

moment.duration(928515).format();
//"15:29"

@christheyounger
Copy link
Author

christheyounger commented Dec 19, 2017

Please see this codepen:
https://codepen.io/darkbluesun/pen/MrygQZ
15.00:29.00 in IE10
I'm happy for you to fork and fix it if I've done something wrong

@jsmreese
Copy link
Owner

@darkbluesun It looks like IE10 doesn't have full support for toLocaleString, which is used to format numbers in version 2 of the plugin.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString

Would a polyfill work for you? There look to be a few, but I haven't checked out what options they support. minimumIntegerDigits, minimumFractionDigits, and maximumFractionDigits are required for the basics.

@jsmreese
Copy link
Owner

@darkbluesun as I'm learning, there are lots of environments where you can use moment that do not provide a fully baked toLocaleString implementation. I'm going to see what I can do about getting a fallback version into the plugin.

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

No branches or pull requests

3 participants