]> git.ipfire.org Git - thirdparty/moment.git/commit
Add globalScope hack to more reliably distinguish Node vs browser 2117/head
authorLucas Sanders <git@butterflyhug.com>
Mon, 22 Dec 2014 14:40:13 +0000 (09:40 -0500)
committerLucas Sanders <git@butterflyhug.com>
Mon, 22 Dec 2014 15:12:58 +0000 (10:12 -0500)
commit1601cb1dd7b14277ba8b00cb2ece3ce637923080
tree6e41e64263c94d58348d33f235780176263688a9
parentd69b63fdc4dffa8634a4557fac73453804fbc5a2
Add globalScope hack to more reliably distinguish Node vs browser

See #2092: browser-based apps that have DOM nodes with the id
"global" were being detected as Node apps for purposes of assigning
moment to the runtime's global namespace.  This change is intended
to fix that issue for most practical use cases, hopefully without
breaking anyone's existing usage.

Algorithm:  If `global` is not defined, then we want to use
`window`.  If `global` is defined but `window` is not, then we want
to use `global`.  If both `global` and `window` are defined, then
we want to assign to `global` if `window === global.window` --
otherwise we assume that `global === window.global`, in which case
we want to assign to `window`.
moment.js