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

Fix bugs on Moment.js lazy loading #894

Merged
merged 4 commits into from Feb 18, 2019
Merged

Fix bugs on Moment.js lazy loading #894

merged 4 commits into from Feb 18, 2019

Conversation

davilima6
Copy link
Member

  • Avoid leaking lazyLoadMomentLocale to global namespace
  • Fix bug by not lower casing mockup-i18n's currentLanguage
  • Fix bug on IE11 due to lack of support for 'includes'

@mister-roboto
Copy link

@davilima6 thanks for creating this Pull Request and help improve Plone!

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass.

Whenever you feel that the pull request is ready to be tested, either start all jenkins jobs pull requests by yourself, or simply add a comment in this pull request stating:

@jenkins-plone-org please run jobs

With this simple comment all the jobs will be started automatically.

Happy hacking!

@davilima6
Copy link
Member Author

@jenkins-plone-org please run jobs

@coveralls
Copy link

coveralls commented Feb 16, 2019

Coverage Status

Coverage increased (+0.03%) to 57.707% when pulling a49ea55 on momentjsLazyLoadLocales into 394625d on master.

- Avoid leaking lazyLoadMomentLocale to global namespace
- Fix not incorrect formatting of mockup-i18n's currentLanguage
- Fix widget breakage on IE11 due to lack of support for 'includes'
@jensens
Copy link
Sponsor Member

jensens commented Feb 16, 2019

Sometimes things are more complex than they seem, right? But now it really looks fine.

'mr ms-my ms my nb ne nl nn pl pt-br pt ro ru se si sk sl sq sr-cyrl ' +
'sr sv sw ta te th tl-ph tlh tr tzl tzm-latn tzm uk uz vi zh-cn zh-tw';

lazyLoadMomentLocale(currentLanguage);
Copy link
Member

Choose a reason for hiding this comment

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

I would move this invocation after the function is defined and would call it without an argument (currentLanguage can be evaluated in the scope of lazyLoadMomentLocale, see comment above).
Not a merge blocker.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. I'll change that.

About the function declaration since it's hoisted should be fine but I'll double check, probably your suggestion makes things more readable.

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed the 2 suggested changes but I must confess I wasn't too sure about the 2nd one. It seems to me not relying on local scope would be safer, for instance the function could become easier to test and also move around, for example, if we wanted it to go in a moment-locale pattern (i don't like bloating the pattern file, in this case it was OK-ish because it's little code but I'd prefer if it looked more similar to the others: define wrapper + extend Base + return extended object. yet I preferred to tackle that in a next PR)

mockup/patterns/moment/pattern.js Show resolved Hide resolved
mockup/patterns/moment/pattern.js Show resolved Hide resolved
@davilima6
Copy link
Member Author

@jenkins-plone-org please run jobs

@davilima6
Copy link
Member Author

@ale-rt, no pain! Just asking for suggestions on how to improve it. I'll merge then, thank you!

@ale-rt
Copy link
Member

ale-rt commented Feb 18, 2019

Test failure unrelated, I am merging this one

@ale-rt ale-rt merged commit 2734523 into master Feb 18, 2019
@ale-rt ale-rt deleted the momentjsLazyLoadLocales branch February 18, 2019 22:59
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.

None yet

5 participants