@@ -17,7 +17,8 @@ function isHostElement(
1717 return (
1818 typeof shadowElement === "object" &&
1919 "$$typeof" in shadowElement &&
20- ( typeof shadowElement . type === "string" || Element . isPrototypeOf ( shadowElement . type ) )
20+ ( typeof shadowElement . type === "string" ||
21+ Element . isPrototypeOf ( shadowElement . type ) )
2122 ) ;
2223}
2324
@@ -38,7 +39,9 @@ export const hostReconcile: Reconciler = (opt) => {
3839 // create new element
3940 const element = untracked ( ( ) => {
4041 const shadowElement = opt . shadowElement as ShadowHostElement ;
41- return typeof shadowElement . type === "string" ? document . createElement ( shadowElement . type ) : new ( shadowElement . type ) ( ) ;
42+ return typeof shadowElement . type === "string"
43+ ? document . createElement ( shadowElement . type )
44+ : new shadowElement . type ( ) ;
4245 } ) ;
4346
4447 opt . shadowCache . node = element ;
@@ -87,10 +90,14 @@ export const hostReconcile: Reconciler = (opt) => {
8790
8891 callback ( evt , ...args ) ;
8992
90- if ( ( opt . shadowElement as ShadowHostElement ) . props . value !== newValue ) {
93+ if (
94+ ( opt . shadowElement as ShadowHostElement ) . props . value !==
95+ newValue
96+ ) {
9197 evt . preventDefault ( ) ;
92- ( evt . currentTarget as HTMLInputElement ) . value =
93- ( opt . shadowElement as ShadowHostElement ) . props . value ;
98+ ( evt . currentTarget as HTMLInputElement ) . value = (
99+ opt . shadowElement as ShadowHostElement
100+ ) . props . value ;
94101 }
95102 } ;
96103 }
@@ -119,11 +126,24 @@ export const hostReconcile: Reconciler = (opt) => {
119126 shadowElement . props . value ;
120127 }
121128 }
122- : ( opt . shadowElement ) . props [ propKey ] ,
129+ : opt . shadowElement . props [ propKey ] ,
123130 ) ;
124131 } else {
125132 untracked ( ( ) => {
126- ( opt . shadowCache . node as any ) [ propKey ] = ( opt . shadowElement as ShadowHostElement ) . props [ propKey ] ;
133+ if ( propKey === "style" ) {
134+ ( opt . shadowCache . node as any ) . setAttribute (
135+ "style" ,
136+ Object . entries (
137+ ( opt . shadowElement as ShadowHostElement ) . props [ propKey ] ,
138+ )
139+ . map ( ( [ key , value ] ) => `${ key } : ${ value } ` )
140+ . join ( ";" ) ,
141+ ) ;
142+ } else {
143+ ( opt . shadowCache . node as any ) [ propKey ] = (
144+ opt . shadowElement as ShadowHostElement
145+ ) . props [ propKey ] ;
146+ }
127147 } ) ;
128148 }
129149
@@ -132,6 +152,17 @@ export const hostReconcile: Reconciler = (opt) => {
132152 }
133153 }
134154
155+ for ( const propKey in ( opt . shadowCache . value as ShadowHostElement ) . props ) {
156+ if ( propKey in opt . shadowElement . props === false ) {
157+ untracked ( ( ) => {
158+ if ( propKey === "style" ) {
159+ ( opt . shadowCache . node as any ) . removeAttribute ( "style" ) ;
160+ }
161+ } ) ;
162+ delete ( opt . shadowCache . value as ShadowHostElement ) . props [ propKey ] ;
163+ }
164+ }
165+
135166 // @TODO Remove unneded props
136167
137168 const previousActiveElement = active . parentElement ;
@@ -157,7 +188,11 @@ export const hostReconcile: Reconciler = (opt) => {
157188 } ) ;
158189
159190 if ( elementNeedsAppending ) {
160- append ( opt . parentElement , opt . previousSibling , opt . shadowCache . node as Node ) ;
191+ append (
192+ opt . parentElement ,
193+ opt . previousSibling ,
194+ opt . shadowCache . node as Node ,
195+ ) ;
161196 }
162197
163198 return opt . shadowCache . node ;
0 commit comments