Skip to content

Commit aeefa41

Browse files
committed
docs: add comment for circular reference
1 parent e7a7597 commit aeefa41

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

packages/plugin-vue/src/handleHotUpdate.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,25 @@ export function isOnlyTemplateChanged(
202202
)
203203
}
204204

205-
function deepEqual(obj1: any, obj2: any, excludeProps: string[] = [], deepParentsOfObj1: any[] = []): boolean {
205+
function deepEqual(
206+
obj1: any,
207+
obj2: any,
208+
excludeProps: string[] = [],
209+
deepParentsOfObj1: any[] = [],
210+
): boolean {
206211
// Check if both objects are of the same type
207212
if (typeof obj1 !== typeof obj2) {
208213
return false
209214
}
210215

211216
// Check if both objects are primitive types or null
212-
if (obj1 == null || obj2 == null || typeof obj1 !== 'object' || deepParentsOfObj1.includes(obj1)) {
217+
// or circular reference
218+
if (
219+
obj1 == null ||
220+
obj2 == null ||
221+
typeof obj1 !== 'object' ||
222+
deepParentsOfObj1.includes(obj1)
223+
) {
213224
return obj1 === obj2
214225
}
215226

@@ -229,7 +240,12 @@ function deepEqual(obj1: any, obj2: any, excludeProps: string[] = [], deepParent
229240
continue
230241
}
231242

232-
if (!deepEqual(obj1[key], obj2[key], excludeProps, [...deepParentsOfObj1, obj1])) {
243+
if (
244+
!deepEqual(obj1[key], obj2[key], excludeProps, [
245+
...deepParentsOfObj1,
246+
obj1,
247+
])
248+
) {
233249
return false
234250
}
235251
}

0 commit comments

Comments
 (0)