Ensure _.noConflict only restores _ if lodash is the current _ value.

This commit is contained in:
John-David Dalton
2016-01-20 23:13:18 -06:00
parent 01819e7a5a
commit 9aa56630ab
2 changed files with 17 additions and 1 deletions

View File

@@ -13230,7 +13230,9 @@
* var lodash = _.noConflict();
*/
function noConflict() {
root._ = oldDash;
if (root._ === this) {
root._ = oldDash;
}
return this;
}

View File

@@ -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);