From f00cbfadab6151b287cfdcf61e8d52fd8067980b Mon Sep 17 00:00:00 2001 From: Nicolas Accetta Date: Mon, 22 Jan 2024 13:40:21 -0300 Subject: [PATCH] feat: remove hypescript usage --- packages/button/src/index.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/button/src/index.ts b/packages/button/src/index.ts index 8d821c4..c8945f0 100644 --- a/packages/button/src/index.ts +++ b/packages/button/src/index.ts @@ -27,13 +27,14 @@ class Button extends HTMLButtonElement { if (newValue === "toggle") { const pressed = this.getAttribute("data-pressed") this.setAttribute("aria-pressed", pressed ?? "false") - this.setAttribute("_", ` - on click - if @aria-pressed equals 'true' - set @aria-pressed to 'false' - else - set @aria-pressed to 'true' - `) + this.addEventListener("click", () => { + const ariaPressed = this.getAttribute("aria-pressed") ?? "false" + if (ariaPressed === "true") { + this.setAttribute("aria-pressed", "false") + } else { + this.setAttribute("aria-pressed", "true") + } + }) } // menu