@@ -8,7 +8,7 @@ type PropNames<Props> = Array<PropName<Props>>
88
99export interface R2WCOptions < Props > {
1010 shadow ?: "open" | "closed"
11- props ?: PropNames < Props > | Record < PropName < Props > , R2WCType >
11+ props ?: PropNames < Props > | Partial < Record < PropName < Props > , R2WCType > >
1212}
1313
1414export interface R2WCRenderer < Props , Context > {
@@ -52,7 +52,7 @@ export default function r2wc<Props extends R2WCBaseProps, Context>(
5252 ? options . props . slice ( )
5353 : ( Object . keys ( options . props ) as PropNames < Props > )
5454
55- const propTypes = { } as Record < PropName < Props > , R2WCType >
55+ const propTypes = { } as Partial < Record < PropName < Props > , R2WCType > >
5656 const mapPropAttribute = { } as Record < PropName < Props > , string >
5757 const mapAttributeProp = { } as Record < string , PropName < Props > >
5858 for ( const prop of propNames ) {
@@ -93,7 +93,7 @@ export default function r2wc<Props extends R2WCBaseProps, Context>(
9393 const attribute = mapPropAttribute [ prop ]
9494 const value = this . getAttribute ( attribute )
9595 const type = propTypes [ prop ]
96- const transform = transforms [ type ]
96+ const transform = type ? transforms [ type ] : null
9797
9898 if ( transform ?. parse && value ) {
9999 //@ts -ignore
@@ -123,7 +123,7 @@ export default function r2wc<Props extends R2WCBaseProps, Context>(
123123 ) {
124124 const prop = mapAttributeProp [ attribute ]
125125 const type = propTypes [ prop ]
126- const transform = transforms [ type ]
126+ const transform = type ? transforms [ type ] : null
127127
128128 if ( prop in propTypes && transform ?. parse && value ) {
129129 //@ts -ignore
@@ -161,7 +161,7 @@ export default function r2wc<Props extends R2WCBaseProps, Context>(
161161 set ( value ) {
162162 this [ propsSymbol ] [ prop ] = value
163163
164- const transform = transforms [ type ]
164+ const transform = type ? transforms [ type ] : null
165165 if ( transform ?. stringify ) {
166166 //@ts -ignore
167167 const attributeValue = transform . stringify ( value , attribute , this )
@@ -170,6 +170,8 @@ export default function r2wc<Props extends R2WCBaseProps, Context>(
170170 if ( oldAttributeValue !== attributeValue ) {
171171 this . setAttribute ( attribute , attributeValue )
172172 }
173+ } else {
174+ this [ renderSymbol ] ( )
173175 }
174176 } ,
175177 } )
0 commit comments