Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export {
hasContext,
tick,
createEventDispatcher,
Action,
SvelteComponentDev as SvelteComponent,
SvelteComponentTyped
} from 'svelte/internal';
17 changes: 17 additions & 0 deletions src/runtime/internal/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,3 +732,20 @@ export function get_custom_elements_slots(element: HTMLElement) {
});
return result;
}


type ActionWithParams<Node extends HTMLElement = HTMLElement, Params = any> = (
node: Node,
options: Params
) => {
update?: (params: Params) => void
destroy?: () => void
}

type ActionWithoutParams<Node extends HTMLElement = HTMLElement> = (node: Node) => {
destroy?: () => void
}

export type Action<Node extends HTMLElement = HTMLElement, Params = void> = void extends Params
? ActionWithoutParams<Node>
: ActionWithParams<Node, Params>