@@ -8,7 +8,7 @@ type PropNames<Props> = Array<PropName<Props>>
8
8
9
9
export interface R2WCOptions < Props > {
10
10
shadow ?: "open" | "closed"
11
- props ?: PropNames < Props > | Record < PropName < Props > , R2WCType >
11
+ props ?: PropNames < Props > | Partial < Record < PropName < Props > , R2WCType > >
12
12
}
13
13
14
14
export interface R2WCRenderer < Props , Context > {
@@ -52,7 +52,7 @@ export default function r2wc<Props extends R2WCBaseProps, Context>(
52
52
? options . props . slice ( )
53
53
: ( Object . keys ( options . props ) as PropNames < Props > )
54
54
55
- const propTypes = { } as Record < PropName < Props > , R2WCType >
55
+ const propTypes = { } as Partial < Record < PropName < Props > , R2WCType > >
56
56
const mapPropAttribute = { } as Record < PropName < Props > , string >
57
57
const mapAttributeProp = { } as Record < string , PropName < Props > >
58
58
for ( const prop of propNames ) {
@@ -93,7 +93,7 @@ export default function r2wc<Props extends R2WCBaseProps, Context>(
93
93
const attribute = mapPropAttribute [ prop ]
94
94
const value = this . getAttribute ( attribute )
95
95
const type = propTypes [ prop ]
96
- const transform = transforms [ type ]
96
+ const transform = type ? transforms [ type ] : null
97
97
98
98
if ( transform ?. parse && value ) {
99
99
//@ts -ignore
@@ -123,7 +123,7 @@ export default function r2wc<Props extends R2WCBaseProps, Context>(
123
123
) {
124
124
const prop = mapAttributeProp [ attribute ]
125
125
const type = propTypes [ prop ]
126
- const transform = transforms [ type ]
126
+ const transform = type ? transforms [ type ] : null
127
127
128
128
if ( prop in propTypes && transform ?. parse && value ) {
129
129
//@ts -ignore
@@ -161,7 +161,7 @@ export default function r2wc<Props extends R2WCBaseProps, Context>(
161
161
set ( value ) {
162
162
this [ propsSymbol ] [ prop ] = value
163
163
164
- const transform = transforms [ type ]
164
+ const transform = type ? transforms [ type ] : null
165
165
if ( transform ?. stringify ) {
166
166
//@ts -ignore
167
167
const attributeValue = transform . stringify ( value , attribute , this )
@@ -170,6 +170,8 @@ export default function r2wc<Props extends R2WCBaseProps, Context>(
170
170
if ( oldAttributeValue !== attributeValue ) {
171
171
this . setAttribute ( attribute , attributeValue )
172
172
}
173
+ } else {
174
+ this [ renderSymbol ] ( )
173
175
}
174
176
} ,
175
177
} )
0 commit comments