Browse Source

handle circular reference in looseEqual (fix #5055)

dev
Evan You 8 years ago
parent
commit
0b902e0c28
  1. 7
      src/shared/util.js

7
src/shared/util.js

@ -211,7 +211,12 @@ export function looseEqual (a: mixed, b: mixed): boolean {
const isObjectA = isObject(a)
const isObjectB = isObject(b)
if (isObjectA && isObjectB) {
return JSON.stringify(a) === JSON.stringify(b)
try {
return JSON.stringify(a) === JSON.stringify(b)
} catch (e) {
// possible circular reference
return a === b
}
} else if (!isObjectA && !isObjectB) {
return String(a) === String(b)
} else {

Loading…
Cancel
Save