Skip to content

Commit c6b092e

Browse files
committed
preserve reference to props.$$events
1 parent f110bda commit c6b092e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/svelte/src/legacy/legacy-client.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function asClassComponent(component) {
5353

5454
class Svelte4Component {
5555
/** @type {any} */
56-
#events = {};
56+
#events;
5757

5858
/** @type {Record<string, any>} */
5959
#instance;
@@ -70,7 +70,7 @@ class Svelte4Component {
7070
// Using proxy state here isn't completely mirroring the Svelte 4 behavior, because mutations to a property
7171
// cause fine-grained updates to only the places where that property is used, and not the entire property.
7272
// Reactive statements and actions (the things where this matters) are handling this properly regardless, so it should be fine in practise.
73-
const props = proxy({ ...(options.props || {}), $$events: this.#events }, false);
73+
const props = proxy({ ...(options.props || {}), $$events: {} }, false);
7474
this.#instance = (options.hydrate ? hydrate : mount)(options.component, {
7575
target: options.target,
7676
props,
@@ -79,6 +79,8 @@ class Svelte4Component {
7979
recover: options.recover
8080
});
8181

82+
this.#events = props.$$events;
83+
8284
for (const key of Object.keys(this.#instance)) {
8385
if (key === '$set' || key === '$destroy' || key === '$on') continue;
8486
define_property(this, key, {

0 commit comments

Comments
 (0)