mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Fix iteration order if sources in defaults.
This commit is contained in:
14
defaults.js
14
defaults.js
@@ -28,15 +28,15 @@ const hasOwnProperty = objectProto.hasOwnProperty
|
|||||||
*/
|
*/
|
||||||
function defaults(object, ...sources) {
|
function defaults(object, ...sources) {
|
||||||
object = Object(object)
|
object = Object(object)
|
||||||
let length = sources.length
|
let srcIndex = -1
|
||||||
while (length--) {
|
let srcLength = sources.length
|
||||||
const source = sources[length]
|
while (++srcIndex < srcLength) {
|
||||||
|
const source = sources[srcIndex]
|
||||||
const props = keysIn(source)
|
const props = keysIn(source)
|
||||||
let index = -1
|
let propsIndex = -1
|
||||||
const propsLength = props.length
|
const propsLength = props.length
|
||||||
|
while (++propsIndex < propsLength) {
|
||||||
while (++index < propsLength) {
|
const key = props[propsIndex]
|
||||||
const key = props[index]
|
|
||||||
const value = object[key]
|
const value = object[key]
|
||||||
if (value === undefined ||
|
if (value === undefined ||
|
||||||
(eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
|
(eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user