Skip to content

Commit 1b29dee

Browse files
committed
refactor(core): Append elements to documentElement instead of body
1 parent 5e26c8d commit 1b29dee

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ export const start = () => {
283283
initReactScanOverlay();
284284

285285
const overlayElement = document.createElement('react-scan-overlay') as any;
286-
document.body.appendChild(overlayElement);
286+
document.documentElement.appendChild(overlayElement);
287287

288288
if (options.showToolbar) {
289289
createToolbar();

src/core/web/toolbar.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ export const createToolbar = () => {
368368
}
369369
`;
370370

371-
document.head.appendChild(styleElement);
371+
if (document.head) document.head.appendChild(styleElement);
372372

373373
const inspectBtn = toolbar.querySelector<HTMLButtonElement>(
374374
`#${INSPECT_TOGGLE_ID}`,
@@ -391,7 +391,7 @@ export const createToolbar = () => {
391391

392392
let isActive = !ReactScanInternals.isPaused;
393393

394-
document.body.appendChild(toolbar);
394+
document.documentElement.appendChild(toolbar);
395395

396396
let initialX = 0;
397397
let initialY = 0;
@@ -613,7 +613,7 @@ export const createToolbar = () => {
613613
if (existing) existing.remove();
614614

615615
if (!toolbar.parentElement) {
616-
document.body.appendChild(toolbar);
616+
document.documentElement.appendChild(toolbar);
617617
}
618618

619619
ReactScanInternals.inspectState = {

0 commit comments

Comments
 (0)