Add type=button handling

Fixes #22
This commit is contained in:
Ryan Gossiaux
2021-12-22 13:07:16 -08:00
parent 96b165acc0
commit a7e8be2c14
7 changed files with 30 additions and 4 deletions

View File

@@ -10,6 +10,7 @@
import type { SupportedAs } from "$lib/internal/elements";
import type { HTMLActionArray } from "$lib/hooks/use-actions";
import Render from "$lib/utils/Render.svelte";
import { resolveButtonType } from "$lib/utils/resolve-button-type";
const forwardEvents = forwardEventsBuilder(get_current_component(), [
"change",
]);
@@ -49,6 +50,7 @@
$: propsWeControl = {
id,
role: "switch",
type: resolveButtonType({ type: $$props.type, as }, $switchStore),
tabIndex: 0,
"aria-checked": checked,
"aria-labelledby": $labelContext?.labelIds,
@@ -80,7 +82,6 @@
{slotProps}
use={[...use, forwardEvents]}
name={"Switch"}
bind:el={$switchStore}
on:click={handleClick}
on:keyup={handleKeyUp}
on:keypress={handleKeyPress}