Skip to content

Commit

Permalink
Avoid the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Mar 29, 2024
1 parent 3d2b2cd commit e11d6ed
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/contentScript/sidebarDomControllerLite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ import { uuidv4 } from "@/types/helpers";
export const SIDEBAR_WIDTH_CSS_PROPERTY = "--pb-sidebar-width";
const ORIGINAL_MARGIN_CSS_PROPERTY = "--pb-original-margin-right";

// Use ? because it's somehow not defined in e2e tests. But otherwise it will always be defined.
// eslint-disable-next-line local-rules/persistBackgroundData -- Static
const html: HTMLElement = globalThis.document?.documentElement;
const SIDEBAR_WIDTH_PX = 400;

function storeOriginalCSSOnce() {
const html = document.documentElement;

if (html.style.getPropertyValue(ORIGINAL_MARGIN_CSS_PROPERTY)) {
return;
}
Expand All @@ -57,6 +56,7 @@ function storeOriginalCSSOnce() {
}

function setSidebarWidth(pixels: number): void {
const html = document.documentElement;
html.style.setProperty(SIDEBAR_WIDTH_CSS_PROPERTY, `${pixels}px`);
}

Expand All @@ -66,7 +66,7 @@ function setSidebarWidth(pixels: number): void {
export function getSidebarElement(): Element | null {
expectContext("contentScript");

return html.querySelector(`#${PANEL_FRAME_ID}`);
return document.documentElement.querySelector(`#${PANEL_FRAME_ID}`);
}

/**
Expand Down Expand Up @@ -122,7 +122,7 @@ export function insertSidebarFrame(): boolean {

const wrapper = shadowWrap(iframe);
wrapper.id = PANEL_FRAME_ID;
html.append(wrapper);
document.documentElement.append(wrapper);

iframe.animate([{ translate: "50%" }, { translate: 0 }], {
duration: 500,
Expand Down

0 comments on commit e11d6ed

Please sign in to comment.