bv-ui-core 2.9.10 → 2.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ var getGlobal = function () {
18
18
  windows object during transpilation with __esModule being set. Below code would support
19
19
  global import in all bundle use cases
20
20
  */
21
- if (globalObj && globalObj.__esModule) {
21
+ if (globalObj && globalObj.__esModule && typeof window !== 'undefined' && globalObj !== window) {
22
22
  const proxyGlobal = new Proxy(globalObj, {
23
23
  get: function (target, prop) {
24
24
  if (prop === 'default') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bv-ui-core",
3
- "version": "2.9.10",
3
+ "version": "2.9.12",
4
4
  "license": "Apache 2.0",
5
5
  "description": "Bazaarvoice UI-related JavaScript",
6
6
  "repository": {
@@ -24,4 +24,23 @@ describe('lib/global', function () {
24
24
  }
25
25
  });
26
26
 
27
+ it('should not wrap window in a Proxy when globalObj is window even if __esModule is set', function () {
28
+ if (typeof window !== 'undefined') {
29
+ window.__esModule = true;
30
+ var result = require('../../../lib/global');
31
+ // When globalObj === window, the proxy branch should be skipped,
32
+ // so the result should be strictly equal to window.
33
+ expect(result).to.equal(window);
34
+ delete window.__esModule;
35
+ }
36
+ });
37
+
38
+ it('should return the global object directly when __esModule is not set', function () {
39
+ if (typeof window !== 'undefined') {
40
+ delete window.__esModule;
41
+ var result = require('../../../lib/global');
42
+ expect(result).to.equal(window);
43
+ }
44
+ });
45
+
27
46
  });