bv-ui-core
Advanced tools
Comparing version 2.8.0 to 2.8.1
@@ -9,9 +9,34 @@ /** | ||
var getGlobal = function () { | ||
if (typeof globalThis !== 'undefined') { return globalThis; } | ||
if (typeof window !== 'undefined') { return window; } | ||
if (typeof self !== 'undefined') { return self; } | ||
if (typeof global !== 'undefined') { return global; } | ||
throw new Error('unable to locate global object'); | ||
var globalObj = (function () { | ||
if (typeof globalThis !== 'undefined') { return globalThis; } | ||
if (typeof window !== 'undefined') { return window; } | ||
if (typeof self !== 'undefined') { return self; } | ||
if (typeof global !== 'undefined') { return global; } | ||
throw new Error('unable to locate global object'); | ||
})() | ||
/* | ||
The below code was added in case there is pollution in global namespace | ||
windows object during transpilation with __esModule being set. Below code would support | ||
global import in all bundle use cases | ||
*/ | ||
if (globalObj && globalObj.__esModule) { | ||
const override = { | ||
get: function (target, prop, receiver) { | ||
if (prop === 'default') { | ||
return target | ||
} | ||
return Reflect.get(receiver, prop, target) | ||
}, | ||
set: function (target, prop, value) { | ||
Reflect.set(target, prop, value) | ||
}, | ||
}; | ||
const proxyGlobal = new Proxy(globalObj, override) | ||
return proxyGlobal | ||
} | ||
return globalObj | ||
}; | ||
module.exports = getGlobal(); |
{ | ||
"name": "bv-ui-core", | ||
"version": "2.8.0", | ||
"version": "2.8.1", | ||
"license": "Apache 2.0", | ||
@@ -5,0 +5,0 @@ "description": "Bazaarvoice UI-related JavaScript", |
@@ -18,2 +18,11 @@ /** | ||
it('should export window with default pointing to windows if __esModule is set', function () { | ||
// If we have access to the window object, compare against it. | ||
if (typeof window !== 'undefined') { | ||
window.__esModule = true | ||
var global = require('../../../lib/global') | ||
expect(global).to.eql(window); | ||
} | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
243947
5712