lodash: Add native method overwrite detection and optimize bind for native bind. [jddalton]

Former-commit-id: d968957e494fb828df155d2f9b0d3faf24e38b5e
This commit is contained in:
John-David Dalton
2012-05-06 17:55:23 -04:00
parent 6d3d5f77bc
commit 14c8863657
3 changed files with 59 additions and 9 deletions

View File

@@ -12,7 +12,20 @@
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<script src="../vendor/qunit/qunit/qunit.js"></script>
<script>var _2, _3, _ = 1;</script>
<script>
var _2,
_3 = Object.keys;
Object.keys = function() { return []; };
</script>
<script src="../lodash.js"></script>
<script>
var lodashBadKeys = _,
_ = 1;
Object.keys = _3;
_3 = void 0;
</script>
<script src="../lodash.js"></script>
<script src="../vendor/requirejs/require.js"></script>
<script>

View File

@@ -62,6 +62,14 @@
skipTest(1)
}
});
test('avoids overwritten native methods', function() {
if (window.lodashBadKeys) {
notDeepEqual(lodashBadKeys.keys({ 'a': 1 }), []);
} else {
skipTest(1);
}
});
}());
/*--------------------------------------------------------------------------*/