Fix iteration order if sources in defaults.

This commit is contained in:
John-David Dalton
2017-02-13 17:36:27 -08:00
parent e31e1306c8
commit 43bcecf52f

View File

@@ -28,15 +28,15 @@ const hasOwnProperty = objectProto.hasOwnProperty
*/
function defaults(object, ...sources) {
object = Object(object)
let length = sources.length
while (length--) {
const source = sources[length]
let srcIndex = -1
let srcLength = sources.length
while (++srcIndex < srcLength) {
const source = sources[srcIndex]
const props = keysIn(source)
let index = -1
let propsIndex = -1
const propsLength = props.length
while (++index < propsLength) {
const key = props[index]
while (++propsIndex < propsLength) {
const key = props[propsIndex]
const value = object[key]
if (value === undefined ||
(eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {