Thomas G. Lopes
convert actions to attachments (#84)
fbef5e8 unverified
raw
history blame
249 Bytes
import { tick } from "svelte";
import type { Attachment } from "svelte/attachments";
export function autofocus(enabled = true): Attachment<HTMLElement> {
return node => {
if (!enabled) return;
tick().then(() => {
node.focus();
});
};
}