diff --git a/lodash.js b/lodash.js index 7f7b37407..7c5909153 100644 --- a/lodash.js +++ b/lodash.js @@ -248,11 +248,12 @@ 'init': 'object', 'top': 'for (var source, sourceIndex = 1, length = arguments.length; sourceIndex < length; sourceIndex++) {\n' + - ' source = arguments[sourceIndex]', + ' source = arguments[sourceIndex];\n' + + (hasDontEnumBug ? ' if (source) {' : ''), 'loopExp': 'index in source', 'useHas': false, 'inLoop': 'object[index] = source[index]', - 'bottom': '}' + 'bottom': (hasDontEnumBug ? ' }\n' : '') + '}' }; /** Reusable iterator options for `filter` and `reject` */ diff --git a/perf/index.html b/perf/index.html index f6746b4c2..bb731ce44 100644 --- a/perf/index.html +++ b/perf/index.html @@ -30,7 +30,7 @@ }()); window.onload = function() { - var sibling = document.scripts[0], + var sibling = document.getElementsByTagName('script')[0], script = document.createElement('script'); document.getElementById('FirebugUI').style.height = '100%'; diff --git a/test/backbone.html b/test/backbone.html index 63bb13f1a..87bcc06e3 100644 --- a/test/backbone.html +++ b/test/backbone.html @@ -5,7 +5,10 @@ Backbone Test Suite diff --git a/test/test.js b/test/test.js index 90d057f24..92f426f10 100644 --- a/test/test.js +++ b/test/test.js @@ -149,6 +149,14 @@ QUnit.module('lodash.extend'); (function() { + test('should not error on `null` or `undefined` sources (test in IE < 9)', function() { + try { + deepEqual(_.extend({}, null, undefined, { 'a': 1 }), { 'a': 1 }); + } catch(e) { + ok(false); + } + }); + test('skips the prototype property of functions (test in Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1)', function() { function Foo() {} Foo.prototype.c = 3;