mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Ensure _.noConflict only restores _ if lodash is the current _ value.
This commit is contained in:
@@ -13230,7 +13230,9 @@
|
||||
* var lodash = _.noConflict();
|
||||
*/
|
||||
function noConflict() {
|
||||
root._ = oldDash;
|
||||
if (root._ === this) {
|
||||
root._ = oldDash;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
14
test/test.js
14
test/test.js
@@ -14297,6 +14297,20 @@
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('should restore `_` only if `lodash` is the current `_` value', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
if (!isModularize) {
|
||||
var object = root._ = {};
|
||||
assert.strictEqual(_.noConflict(), oldDash);
|
||||
assert.strictEqual(root._, object);
|
||||
root._ = oldDash;
|
||||
}
|
||||
else {
|
||||
skipTest(assert, 2);
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('should work with a `root` of `this`', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user