moment/moment — pull request #2117 by butterflyhug (2014-12-22 15:14:29+00:00)
Title: Add globalScope hack to more reliably distinguish Node vs browser

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`.

This is an actually working version of my suggestion from #2092.