From b5477a405965898b1d34b62b47e3c740cfd8a822 Mon Sep 17 00:00:00 2001 From: Xmader Date: Thu, 21 Jan 2021 23:40:53 -0500 Subject: [PATCH] fix: btns position --- src/btn.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/btn.ts b/src/btn.ts index b9d882e..35f90a2 100644 --- a/src/btn.ts +++ b/src/btn.ts @@ -15,13 +15,13 @@ export enum ICON { } const getBtnContainer = (): HTMLDivElement => { - const els = [...document.querySelectorAll('*')].reverse() + const els = [...document.querySelectorAll('span')] const el = els.find(b => { const text = b?.textContent?.replace(/\s/g, '') || '' return text.includes('Download') || text.includes('Print') }) as HTMLDivElement | null const btnParent = el?.parentElement?.parentElement as HTMLDivElement | undefined - if (!btnParent) throw new Error('btn parent not found') + if (!btnParent || !(btnParent instanceof HTMLDivElement)) throw new Error('btn parent not found') return btnParent } @@ -139,6 +139,8 @@ export class BtnList { newParent.append(...this.list.map(e => cloneBtn(e))) shadow.append(newParent) + // default position + newParent.style.top = '0px' try { const anchorDiv = this.getBtnParent() const pos = () => this._positionBtns(anchorDiv, newParent)