Skip to content

Commit 68ba69c

Browse files
authored
Merge pull request #279 from GordonSmith/IS_CONNECTED
2 parents bf8ccff + 08b3e79 commit 68ba69c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/widgets/src/widget.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,10 +1070,10 @@ export namespace Widget {
10701070
if (widget.parent) {
10711071
throw new Error('Cannot attach a child widget.');
10721072
}
1073-
if (widget.isAttached || document.body.contains(widget.node)) {
1073+
if (widget.isAttached || widget.node.isConnected) {
10741074
throw new Error('Widget is already attached.');
10751075
}
1076-
if (!document.body.contains(host)) {
1076+
if (!host.isConnected) {
10771077
throw new Error('Host is not attached.');
10781078
}
10791079
MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);
@@ -1094,7 +1094,7 @@ export namespace Widget {
10941094
if (widget.parent) {
10951095
throw new Error('Cannot detach a child widget.');
10961096
}
1097-
if (!widget.isAttached || !document.body.contains(widget.node)) {
1097+
if (!widget.isAttached || !widget.node.isConnected) {
10981098
throw new Error('Widget is not attached.');
10991099
}
11001100
MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);

0 commit comments

Comments
 (0)