fix issue #2520 - set scriptGlobalName causing an exception (#2521)

* fix issue #2520 - set scriptGlobalName causing an exception

* fix tests

Co-authored-by: tomer <tomer@securedtouch.com>
This commit is contained in:
Tomer Hadad
2020-03-23 12:33:46 +02:00
committed by GitHub
parent 49dc9d38e8
commit 9fb1097f64
3 changed files with 6 additions and 6 deletions

View File

@@ -23,8 +23,8 @@ var baseRequireConfig = {
include: ['modernizr-init'],
fileExclusionRegExp: /^(.git|node_modules|modulizr|media|test)$/,
wrap: {
start: '\n;(function(window, document, undefined){',
end: '})(window, document);'
start: '\n;(function(scriptGlobalObject, window, document, undefined){',
end: '})(window, window, document);'
},
onBuildWrite: function(id, path, contents) {
if (this.optimize === 'uglify') {
@@ -83,7 +83,7 @@ function build(generate, generateBanner, pkg) {
}
if(config.scriptGlobalName) {
requireConfig.wrap.end = '})(' + config.scriptGlobalName + ', document);';
requireConfig.wrap.end = '})(' + config.scriptGlobalName + ', window, document);';
}
requireConfig.out = function(output) {

View File

@@ -76,7 +76,7 @@ define(['lodash'], function(_) {
' }\n\n';
output += ' // Leak Modernizr namespace\n' +
' window.Modernizr = Modernizr;\n' +
' scriptGlobalObject.Modernizr = Modernizr;\n' +
'\n' +
'});';

View File

@@ -121,7 +121,7 @@ describe('cli/build', function() {
'feature-detects': ['css/boxsizing']
};
build(config, function(file) {
expect(file).to.contain('})(window, document);');
expect(file).to.contain('})(window, window, document);');
done();
});
});
@@ -132,7 +132,7 @@ describe('cli/build', function() {
'feature-detects': ['css/boxsizing']
};
build(config, function(file) {
expect(file).to.contain('})(window.awesomeco, document);');
expect(file).to.contain('})(window.awesomeco, window, document);');
done();
});
});