adopted-ember-addons / ember-moment

MIT License
400 stars 122 forks source link

`services/moment.js` bug in `defaultFormat` #362

Closed jfdnc closed 2 years ago

jfdnc commented 2 years ago

9.0.0 release includes update to MomentService.defaultFormat

https://github.com/adopted-ember-addons/ember-moment/blob/1adc5afc20526af59bde67c7fa8b3e01b9a04971/app/services/moment.js#L5

which is resulting in TypeError: Cannot read property 'outputFormat' of undefined if config.moment isn't defined in the consuming app.

Previous implementation was just silently passing through on this due to get, I believe.

Am I missing something config-wise or are other people experiencing this with the 9.0.0 release?

Techn1x commented 2 years ago

I have also hit this same error, only on 9.0.0. It occurs for me when using the moment helper, if you use it without an output format like this:

{{moment this.someDate "dd-mm-yyyy"}}

(it's expecting both an input and output format)

It's possible other helpers might be affect by this too

davideferre commented 2 years ago

The same for me. Maybe the PR #363 can be improved using the moment default format specified in docs "Default format" subsection

jfdnc commented 2 years ago

@davideferre I believe that passing null is sufficient for allowing moment to default to ISO8601. Explicitly passing that string as a default here would be overspecifying. Previous implementation fell back to null in a similar manner to https://github.com/adopted-ember-addons/ember-moment/pull/363