Skip to content

Commit 0b902e0

Browse files
committed
handle circular reference in looseEqual (fix #5055)
1 parent 46c3866 commit 0b902e0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/shared/util.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ export function looseEqual (a: mixed, b: mixed): boolean {
211211
const isObjectA = isObject(a)
212212
const isObjectB = isObject(b)
213213
if (isObjectA && isObjectB) {
214-
return JSON.stringify(a) === JSON.stringify(b)
214+
try {
215+
return JSON.stringify(a) === JSON.stringify(b)
216+
} catch (e) {
217+
// possible circular reference
218+
return a === b
219+
}
215220
} else if (!isObjectA && !isObjectB) {
216221
return String(a) === String(b)
217222
} else {

0 commit comments

Comments
 (0)