Skip to content

Commit 79cc7bc

Browse files
committed
improve mergeData for edge cases (fix vuejs#4191)
1 parent ab277ad commit 79cc7bc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/core/util/options.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ if (process.env.NODE_ENV !== 'production') {
4040
* Helper that recursively merges two data objects together.
4141
*/
4242
function mergeData (to: Object, from: ?Object): Object {
43+
if (!from) return to
4344
let key, toVal, fromVal
44-
for (key in from) {
45+
const keys = Object.keys(from)
46+
for (let i = 0; i < keys.length; i++) {
47+
key = keys[i]
4548
toVal = to[key]
4649
fromVal = from[key]
4750
if (!hasOwn(to, key)) {
4851
set(to, key, fromVal)
49-
} else if (isObject(toVal) && isObject(fromVal)) {
52+
} else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
5053
mergeData(toVal, fromVal)
5154
}
5255
}

0 commit comments

Comments
 (0)