|
| 1 | +/* |
| 2 | +https://github.com/ungap/global-this/blob/v0.4.4/esm/index.js |
| 3 | +
|
| 4 | +Copyright (c) 2020, Andrea Giammarchi, @WebReflection |
| 5 | +
|
| 6 | +Permission to use, copy, modify, and/or distribute this software for any |
| 7 | +purpose with or without fee is hereby granted, provided that the above |
| 8 | +copyright notice and this permission notice appear in all copies. |
| 9 | +
|
| 10 | +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
| 11 | +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 12 | +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
| 13 | +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 14 | +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE |
| 15 | +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | +PERFORMANCE OF THIS SOFTWARE. |
| 17 | +
|
| 18 | +------- |
| 19 | +
|
| 20 | +Patches for use in QUnit: |
| 21 | +
|
| 22 | +- 2021-02-25: Export as module only, don't change global scope as QUnit must not |
| 23 | + affect the host context (e.g. people may test their application intentionally |
| 24 | + with different or no polyfills and we must not affect that). |
| 25 | +
|
| 26 | +*/ |
| 27 | + |
| 28 | +let foundGlobalThis; |
| 29 | + |
| 30 | +(function (Object) { |
| 31 | + if (typeof globalThis === "object") { |
| 32 | + foundGlobalThis = globalThis; |
| 33 | + } else { |
| 34 | + this |
| 35 | + ? get() |
| 36 | + : (Object.defineProperty(Object.prototype, "_T_", { |
| 37 | + configurable: true, |
| 38 | + get: get, |
| 39 | + }), |
| 40 | + _T_); |
| 41 | + |
| 42 | + function get() { |
| 43 | + foundGlobalThis = this || self; |
| 44 | + delete Object.prototype._T_; |
| 45 | + } |
| 46 | + } |
| 47 | +})(Object); |
| 48 | + |
| 49 | +export default foundGlobalThis; |
0 commit comments