From 89763ee762277d64b7ee330963f5148fbe3753bd Mon Sep 17 00:00:00 2001 From: Xmader Date: Mon, 23 Nov 2020 12:02:41 -0500 Subject: [PATCH] fix: buttons do appear but they do nothing --- src/btn.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/btn.ts b/src/btn.ts index 9be3ab1..dcb1dd6 100644 --- a/src/btn.ts +++ b/src/btn.ts @@ -39,6 +39,12 @@ const buildDownloadBtn = () => { } } +const cloneBtn = (btn: HTMLButtonElement) => { + const n = btn.cloneNode(true) as HTMLButtonElement + n.onclick = btn.onclick + return n +} + interface BtnOptions { readonly name: string; readonly action: BtnAction; @@ -97,7 +103,7 @@ export class BtnList { // hide buttons using the shadow DOM const newParent = btnParent.cloneNode(false) as HTMLDivElement - newParent.append(...this.list.map(e => e.cloneNode(true))) + newParent.append(...this.list.map(e => cloneBtn(e))) shadow.append(newParent) const slot = document.createElement('slot') shadow.append(slot)