@@ -35,6 +35,7 @@ export const hostReconcile: Reconciler = (opt) => {
3535 } else {
3636 // remove old element
3737 opt . shadowCache . remove ( ) ;
38+ opt . shadowCache . abortController = new AbortController ( ) ;
3839
3940 // create new element
4041 const element = untracked ( ( ) => {
@@ -51,20 +52,6 @@ export const hostReconcile: Reconciler = (opt) => {
5152 props : { } ,
5253 children : [ ] ,
5354 } ;
54- opt . shadowCache . unmount = function ( ) {
55- delete ( this . node as any ) [ getParentSymbol ] ;
56- delete ( this as any ) . unmount ;
57- for ( const propKey in ( this . value as ShadowHostElement ) . props ) {
58- if ( propKey . startsWith ( EVENT_PREFIX ) ) {
59- ( this . node as any ) . removeEventListener (
60- propKey . slice ( EVENT_PREFIX . length ) ,
61- ( this . value as ShadowHostElement ) . props [ propKey ] ,
62- ) ;
63- delete ( this . value as ShadowHostElement ) . props [ propKey ] ;
64- }
65- }
66- this . unmount ( ) ;
67- } ;
6855
6956 elementNeedsAppending = true ;
7057 }
@@ -80,54 +67,38 @@ export const hostReconcile: Reconciler = (opt) => {
8067 opt . shadowElement . props [ propKey ]
8168 ) {
8269 if ( propKey . startsWith ( EVENT_PREFIX ) === true ) {
83- if ( opt . shadowElement . type === "input" && propKey === "oninput" ) {
84- const callback = opt . shadowElement . props [ propKey ] ;
85- opt . shadowElement . props [ propKey ] = (
86- evt : KeyboardEvent ,
87- ...args : any [ ]
88- ) => {
89- const newValue = ( evt . currentTarget as HTMLInputElement ) . value ;
90-
91- callback ( evt , ...args ) ;
92-
93- if (
94- ( opt . shadowElement as ShadowHostElement ) . props . value !==
95- newValue
96- ) {
97- evt . preventDefault ( ) ;
98- ( evt . currentTarget as HTMLInputElement ) . value = (
99- opt . shadowElement as ShadowHostElement
100- ) . props . value ;
101- }
102- } ;
103- }
70+ if (
71+ propKey in ( opt . shadowCache . value as ShadowHostElement ) . props ===
72+ false
73+ ) {
74+ const eventName = propKey . slice ( EVENT_PREFIX . length ) ;
10475
105- const eventName = propKey . slice ( EVENT_PREFIX . length ) ;
106- if ( propKey in ( opt . shadowCache . value as ShadowHostElement ) . props ) {
107- ( opt . shadowCache . node as Element ) . removeEventListener (
76+ ( opt . shadowCache . node as Element ) . addEventListener (
10877 eventName ,
109- ( opt . shadowCache . value as ShadowHostElement ) . props [ propKey ] , // @TODO doesnt work for oninput
110- ) ;
111- }
78+ ( evt ) => {
79+ const shadowElement = opt . shadowElement as ShadowHostElement ;
80+ const result = shadowElement . props [ propKey ] ( evt ) ;
11281
113- ( opt . shadowCache . node as Element ) . addEventListener (
114- eventName ,
115- opt . shadowElement . type === "input" && propKey === "oninput"
116- ? ( evt : KeyboardEvent , ...args : any [ ] ) => {
117- const shadowElement = opt . shadowElement as ShadowHostElement ;
82+ if ( shadowElement . type === "input" && propKey === "oninput" ) {
11883 const newValue = ( evt . currentTarget as HTMLInputElement )
11984 . value ;
12085
121- shadowElement . props [ propKey ] ( evt , ...args ) ;
122-
12386 if ( shadowElement . props . value !== newValue ) {
12487 evt . preventDefault ( ) ;
12588 ( evt . currentTarget as HTMLInputElement ) . value =
12689 shadowElement . props . value ;
12790 }
12891 }
129- : opt . shadowElement . props [ propKey ] ,
130- ) ;
92+
93+ if ( result instanceof Promise ) {
94+ if ( active . eventPromises !== null ) {
95+ active . eventPromises . push ( result ) ;
96+ }
97+ }
98+ } ,
99+ { signal : opt . shadowCache . abortController ?. signal } ,
100+ ) ;
101+ }
131102 } else {
132103 untracked ( ( ) => {
133104 if ( propKey === "style" ) {
0 commit comments