Skip to content

Commit

Permalink
fix(plugin-vue): hmr throw Maximum call stack size exceeded (fix #325)
Browse files Browse the repository at this point in the history
  • Loading branch information
NateScarlet committed Jan 8, 2024
1 parent 0a3b9a5 commit e7a7597
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/plugin-vue/src/handleHotUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ export function isOnlyTemplateChanged(
)
}

function deepEqual(obj1: any, obj2: any, excludeProps: string[] = []): boolean {
function deepEqual(obj1: any, obj2: any, excludeProps: string[] = [], deepParentsOfObj1: any[] = []): boolean {
// Check if both objects are of the same type
if (typeof obj1 !== typeof obj2) {
return false
}

// Check if both objects are primitive types or null
if (obj1 == null || obj2 == null || typeof obj1 !== 'object') {
if (obj1 == null || obj2 == null || typeof obj1 !== 'object' || deepParentsOfObj1.includes(obj1)) {
return obj1 === obj2
}

Expand All @@ -229,7 +229,7 @@ function deepEqual(obj1: any, obj2: any, excludeProps: string[] = []): boolean {
continue
}

if (!deepEqual(obj1[key], obj2[key], excludeProps)) {
if (!deepEqual(obj1[key], obj2[key], excludeProps, [...deepParentsOfObj1, obj1])) {
return false
}
}
Expand Down

0 comments on commit e7a7597

Please sign in to comment.