Skip to content

Commit e4c86af

Browse files
committed
fix: line authoring crashes when dom Element cannot be removed.
1 parent edbbfb6 commit e4c86af

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/lineAuthor/view/gutter/gutter.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ export class TextGutter extends GutterMarker {
5555
}
5656

5757
destroy(dom: HTMLElement): void {
58-
if (!document.body.contains(dom)) dom.remove();
58+
if (!document.body.contains(dom)) {
59+
try {
60+
dom.remove();
61+
} catch (_error) {
62+
// sometimes, this randomly seems to fail even with the prior check, so we just ignore the error.
63+
}
64+
}
5965
}
6066
}
6167

@@ -117,8 +123,12 @@ export class LineAuthoringGutter extends GutterMarker {
117123
public destroy(dom: HTMLElement): void {
118124
// this is called frequently, when the gutter moves outside of the view.
119125
if (!document.body.contains(dom)) {
120-
dom.remove();
121126
attachedGutterElements.delete(dom);
127+
try {
128+
dom.remove();
129+
} catch (_error) {
130+
// sometimes, this randomly seems to fail even with the prior check, so we just ignore the error.
131+
}
122132
}
123133
}
124134

0 commit comments

Comments
 (0)