Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

using standard polyfill wrapping pattern to access global scope in multiple runtimes #22

Merged
merged 1 commit into from
Oct 31, 2013

Conversation

caridy
Copy link
Collaborator

@caridy caridy commented Oct 30, 2013

Accessing window object directly is not recommended because it bound this polyfill to a browser. Other polyfills are using a more elegant solution to access the global scope.

With this PR, we can guarantee:

  • using this (which is window in the browser, and global in nodejs) as the global scope to augment it with Intl member.
  • preserving OldIntl on the global scope (even though it is not used in this script at the moment).
  • a new Intl will be created everytime that this script gets evaluated.

@andyearnshaw
Copy link
Owner

Yeah, this was always the plan but I never got around to doing it. I'll merge for now and consider other module wrappers when I have more free time.

andyearnshaw added a commit that referenced this pull request Oct 31, 2013
using standard polyfill wrapping pattern to access global scope in multiple runtimes
@andyearnshaw andyearnshaw merged commit 0b652ec into andyearnshaw:master Oct 31, 2013
@caridy
Copy link
Collaborator Author

caridy commented Oct 31, 2013

@ericf didn't get the chance to update the PR to use global instead of globals, @andyearnshaw already merged it. I used globals to match the CLDR polyfill, which apparently defines that as globals to avoid confusions, but anyway, it is just a local variable.

@ericf
Copy link
Collaborator

ericf commented Nov 1, 2013

@andyearnshaw thanks for merging this!

@ericf ericf mentioned this pull request Nov 1, 2013
3 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants