Skip to content

Commit 4c83c7e

Browse files
committed
fix(Bookmark#clone): reset hashValue correctly
fixes #1944 Signed-off-by: Marcel Klehr <[email protected]>
1 parent 29d263d commit 4c83c7e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/lib/Tree.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class Bookmark<L extends TItemLocation> {
9090
clone(withHash?: boolean):Bookmark<L> {
9191
const bookmark = Object.create(this)
9292
if (!withHash) {
93-
bookmark.hashValue = {}
93+
bookmark.hashValue = null
9494
}
9595
return bookmark
9696
}
@@ -307,7 +307,7 @@ export class Folder<L extends TItemLocation> {
307307
}
308308

309309
async hash(preserveOrder = false): Promise<string> {
310-
if (this.hashValue && this.hashValue[String(preserveOrder)]) {
310+
if (this.hashValue && typeof this.hashValue[String(preserveOrder)] !== 'undefined') {
311311
return this.hashValue[String(preserveOrder)]
312312
}
313313

@@ -333,7 +333,7 @@ export class Folder<L extends TItemLocation> {
333333
JSON.stringify({
334334
title: this.title,
335335
children: await Parallel.map(
336-
this.children,
336+
children,
337337
child => child.hash(preserveOrder),
338338
1
339339
)
@@ -347,7 +347,7 @@ export class Folder<L extends TItemLocation> {
347347
// @ts-ignore
348348
return new Folder({
349349
...this.toJSON(),
350-
...(!withHash && { hashValue: {} }),
350+
...(!withHash && { hashValue: null }),
351351
children: this.children.map(child => child.copy(withHash))
352352
})
353353
}
@@ -358,7 +358,7 @@ export class Folder<L extends TItemLocation> {
358358
return new Folder({
359359
...this.toJSON(),
360360
location,
361-
...(!withHash && { hashValue: {} }),
361+
...(!withHash && { hashValue: null }),
362362
children: this.children.map(child => child.copyWithLocation(withHash, location))
363363
})
364364
}

0 commit comments

Comments
 (0)