{
- // If you want to use on:beforeinstallprompt
- 'on:beforeinstallprompt'?: (event: any) => any;
+ // If you want to use the beforeinstallprompt event
+ 'onbeforeinstallprompt'?: (event: any) => any;
// If you want to use myCustomAttribute={..} (note: all lowercase)
mycustomattribute?: any; // You can replace any with something more specific if you like
}
diff --git a/apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-events.md b/apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-events.md
index c9e55deb48..1078efa675 100644
--- a/apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-events.md
+++ b/apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-events.md
@@ -11,6 +11,52 @@ import { on } from 'svelte/events';
## on
+Attaches an event handler to the window and returns a function that removes the handler. Using this
+rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
+(with attributes like `onclick`), which use event delegation for performance reasons
+
+
+
+```ts
+// @noErrors
+function on(
+ window: Window,
+ type: Type,
+ handler: (
+ this: Window,
+ event: WindowEventMap[Type]
+ ) => any,
+ options?: AddEventListenerOptions | undefined
+): () => void;
+```
+
+
+
+## on
+
+Attaches an event handler to the document and returns a function that removes the handler. Using this
+rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
+(with attributes like `onclick`), which use event delegation for performance reasons
+
+
+
+```ts
+// @noErrors
+function on(
+ document: Document,
+ type: Type,
+ handler: (
+ this: Document,
+ event: DocumentEventMap[Type]
+ ) => any,
+ options?: AddEventListenerOptions | undefined
+): () => void;
+```
+
+
+
+## on
+
Attaches an event handler to an element and returns a function that removes the handler. Using this
rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
(with attributes like `onclick`), which use event delegation for performance reasons
@@ -43,6 +89,32 @@ rather than `addEventListener` will preserve the correct order relative to handl
+```ts
+// @noErrors
+function on<
+ Element extends MediaQueryList,
+ Type extends keyof MediaQueryListEventMap
+>(
+ element: Element,
+ type: Type,
+ handler: (
+ this: Element,
+ event: MediaQueryListEventMap[Type]
+ ) => any,
+ options?: AddEventListenerOptions | undefined
+): () => void;
+```
+
+
+
+## on
+
+Attaches an event handler to an element and returns a function that removes the handler. Using this
+rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
+(with attributes like `onclick`), which use event delegation for performance reasons
+
+
+
```ts
// @noErrors
function on(
diff --git a/apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-legacy.md b/apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-legacy.md
index e2c347fb6e..4497cf7de4 100644
--- a/apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-legacy.md
+++ b/apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-legacy.md
@@ -6,7 +6,21 @@ title: svelte/legacy
```js
// @noErrors
-import { asClassComponent, createClassComponent, run } from 'svelte/legacy';
+import {
+ asClassComponent,
+ createBubbler,
+ createClassComponent,
+ handlers,
+ nonpassive,
+ once,
+ passive,
+ preventDefault,
+ run,
+ self,
+ stopImmediatePropagation,
+ stopPropagation,
+ trusted
+} from 'svelte/legacy';
```
## asClassComponent
@@ -33,6 +47,21 @@ function asClassComponent<
+## createBubbler
+
+Function to create a `bubble` function that mimic the behavior of `on:click` without handler available in svelte 4.
+
+
+
+```ts
+// @noErrors
+function createBubbler(): (
+ type: string
+) => (event: Event) => boolean;
+```
+
+
+
## createClassComponent
Takes the same options as a Svelte 4 component and the component function and returns a Svelte 4 compatible component.
@@ -57,6 +86,89 @@ function createClassComponent<
+## handlers
+
+Function to mimic the multiple listeners available in svelte 4
+
+
+
+```ts
+// @noErrors
+function handlers(
+ ...handlers: EventListener[]
+): EventListener;
+```
+
+
+
+## nonpassive
+
+Substitute for the `nonpassive` event modifier, implemented as an action
+
+
+
+```ts
+// @noErrors
+function nonpassive(
+ node: HTMLElement,
+ [event, handler]: [
+ event: string,
+ handler: () => EventListener
+ ]
+): void;
+```
+
+
+
+## once
+
+Substitute for the `once` event modifier
+
+
+
+```ts
+// @noErrors
+function once(
+ fn: (event: Event, ...args: Array) => void
+): (event: Event, ...args: unknown[]) => void;
+```
+
+
+
+## passive
+
+Substitute for the `passive` event modifier, implemented as an action
+
+
+
+```ts
+// @noErrors
+function passive(
+ node: HTMLElement,
+ [event, handler]: [
+ event: string,
+ handler: () => EventListener
+ ]
+): void;
+```
+
+
+
+## preventDefault
+
+Substitute for the `preventDefault` event modifier
+
+
+
+```ts
+// @noErrors
+function preventDefault(
+ fn: (event: Event, ...args: Array) => void
+): (event: Event, ...args: unknown[]) => void;
+```
+
+
+
## run
Runs the given function once immediately on the server, and works like `$effect.pre` on the client.
@@ -70,4 +182,64 @@ function run(fn: () => void | (() => void)): void;
+## self
+
+Substitute for the `self` event modifier
+
+
+
+```ts
+// @noErrors
+function self(
+ fn: (event: Event, ...args: Array) => void
+): (event: Event, ...args: unknown[]) => void;
+```
+
+
+
+## stopImmediatePropagation
+
+Substitute for the `stopImmediatePropagation` event modifier
+
+
+
+```ts
+// @noErrors
+function stopImmediatePropagation(
+ fn: (event: Event, ...args: Array) => void
+): (event: Event, ...args: unknown[]) => void;
+```
+
+
+
+## stopPropagation
+
+Substitute for the `stopPropagation` event modifier
+
+
+
+```ts
+// @noErrors
+function stopPropagation(
+ fn: (event: Event, ...args: Array) => void
+): (event: Event, ...args: unknown[]) => void;
+```
+
+
+
+## trusted
+
+Substitute for the `trusted` event modifier
+
+
+
+```ts
+// @noErrors
+function trusted(
+ fn: (event: Event, ...args: Array) => void
+): (event: Event, ...args: unknown[]) => void;
+```
+
+
+