Skip to content
This repository was archived by the owner on Nov 4, 2020. It is now read-only.

Commit 9962013

Browse files
committed
Small change in generated script to avoid possible collision in window.default
1 parent b9aaa27 commit 9962013

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

browser-entry.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import should from './es6/should';
2-
import root from 'root';
2+
import * as root from 'root';
33

44
var defaultProto = Object.prototype;
55
var defaultProperty = 'should';
@@ -12,14 +12,17 @@ try {
1212
//ignore errors
1313
}
1414

15+
1516
if (typeof define === 'function' && define.amd) {
1617
define([], function() { return should });
1718
} else if (typeof module === 'object' && module.exports) {
1819
module.exports = should;
1920
} else {
20-
root.Should = should;
21+
var _root = root;
22+
23+
_root.Should = should;
2124

22-
Object.defineProperty(root, 'should', {
25+
Object.defineProperty(_root, 'should', {
2326
enumerable: false,
2427
configurable: true,
2528
value: should

should.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
(function (root) {
1010
'use strict';
1111

12-
root = 'default' in root ? root['default'] : root;
13-
1412
var types = {
1513
NUMBER: 'number',
1614
UNDEFINED: 'undefined',
@@ -3810,14 +3808,17 @@
38103808
//ignore errors
38113809
}
38123810

3811+
38133812
if (typeof define === 'function' && define.amd) {
38143813
define([], function() { return should });
38153814
} else if (typeof module === 'object' && module.exports) {
38163815
module.exports = should;
38173816
} else {
3818-
root.Should = should;
3817+
var _root = root;
3818+
3819+
_root.Should = should;
38193820

3820-
Object.defineProperty(root, 'should', {
3821+
Object.defineProperty(_root, 'should', {
38213822
enumerable: false,
38223823
configurable: true,
38233824
value: should

0 commit comments

Comments
 (0)