mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
Ensure the exports object is not a DOM element. [closes #197]
Former-commit-id: 3adb679f7f4d7a64e0bc37ed80a443c211a17510
This commit is contained in:
6
build.js
6
build.js
@@ -529,7 +529,7 @@
|
|||||||
' _ = lodash;',
|
' _ = lodash;',
|
||||||
' lodash.templates = lodash.extend(lodash.templates || {}, templates);',
|
' lodash.templates = lodash.extend(lodash.templates || {}, templates);',
|
||||||
' });',
|
' });',
|
||||||
" } else if (freeExports) {",
|
" } else if (freeExports && !freeExports.nodeType) {",
|
||||||
" _ = require('" + options.moduleId + "');",
|
" _ = require('" + options.moduleId + "');",
|
||||||
" if (freeModule) {",
|
" if (freeModule) {",
|
||||||
' (freeModule.exports = templates).templates = templates;',
|
' (freeModule.exports = templates).templates = templates;',
|
||||||
@@ -2417,9 +2417,9 @@
|
|||||||
}
|
}
|
||||||
// remove `if (freeExports) {...}` if it's empty
|
// remove `if (freeExports) {...}` if it's empty
|
||||||
if (isAMD && isGlobal) {
|
if (isAMD && isGlobal) {
|
||||||
source = source.replace(/(?: *\/\/.*\n)* *(?:else )?if *\(freeExports\) *{\s*}\n+/, '');
|
source = source.replace(/(?: *\/\/.*\n)* *(?:else )?if *\(freeExports.*?\) *{\s*}\n+/, '');
|
||||||
} else {
|
} else {
|
||||||
source = source.replace(/(?: *\/\/.*\n)* *(?:else )?if *\(freeExports\) *{\s*}(?:\s*else *{([\s\S]+?) *})?\n+/, '$1\n');
|
source = source.replace(/(?: *\/\/.*\n)* *(?:else )?if *\(freeExports.*?\) *{\s*}(?:\s*else *{([\s\S]+?) *})?\n+/, '$1\n');
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|||||||
@@ -173,7 +173,7 @@
|
|||||||
nativeRandom = Math.random;
|
nativeRandom = Math.random;
|
||||||
|
|
||||||
/** Detect various environments */
|
/** Detect various environments */
|
||||||
var isIeOpera = !!context.attachEvent,
|
var isIeOpera = reNative.test(context.attachEvent),
|
||||||
isJSC = !/\n{2,}/.test(Function()),
|
isJSC = !/\n{2,}/.test(Function()),
|
||||||
isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera);
|
isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera);
|
||||||
|
|
||||||
@@ -5224,7 +5224,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// check for `exports` after `define` in case a build optimizer adds an `exports` object
|
// check for `exports` after `define` in case a build optimizer adds an `exports` object
|
||||||
else if (freeExports) {
|
else if (freeExports && !freeExports.nodeType) {
|
||||||
// in Node.js or RingoJS v0.8.0+
|
// in Node.js or RingoJS v0.8.0+
|
||||||
if (freeModule) {
|
if (freeModule) {
|
||||||
(freeModule.exports = _)._ = _;
|
(freeModule.exports = _)._ = _;
|
||||||
|
|||||||
@@ -4,12 +4,18 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Lo-Dash Test Suite</title>
|
<title>Lo-Dash Test Suite</title>
|
||||||
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css">
|
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css">
|
||||||
|
<style>
|
||||||
|
#exports {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="qunit"></div>
|
|
||||||
<script src="../vendor/platform.js/platform.js"></script>
|
<script src="../vendor/platform.js/platform.js"></script>
|
||||||
<script src="../vendor/qunit/qunit/qunit.js"></script>
|
<script src="../vendor/qunit/qunit/qunit.js"></script>
|
||||||
<script src="test-ui.js"></script>
|
<script src="test-ui.js"></script>
|
||||||
|
<div id="qunit"></div>
|
||||||
|
<div id="exports"></div>
|
||||||
<script>
|
<script>
|
||||||
// set a bad shim
|
// set a bad shim
|
||||||
Object._keys = Object.keys;
|
Object._keys = Object.keys;
|
||||||
|
|||||||
Reference in New Issue
Block a user