@@ -39,7 +39,14 @@ export function initializeAttrs(instance: HTMLElement, names?: Iterable<string>)
3939 for ( const key of names ) {
4040 const value = ( < Record < PropertyKey , unknown > > ( < unknown > instance ) ) [ key ]
4141 const name = attrToAttributeName ( key )
42- let descriptor : PropertyDescriptor
42+ let descriptor : PropertyDescriptor = {
43+ get ( this : HTMLElement ) : string {
44+ return String ( this . getAttribute ( name ) || '' )
45+ } ,
46+ set ( this : HTMLElement , newValue : string ) {
47+ this . setAttribute ( name , newValue || '' )
48+ }
49+ }
4350 if ( typeof value === 'number' ) {
4451 descriptor = {
4552 get ( this : HTMLElement ) : number {
@@ -58,15 +65,6 @@ export function initializeAttrs(instance: HTMLElement, names?: Iterable<string>)
5865 this . toggleAttribute ( name , newValue )
5966 }
6067 }
61- } else {
62- descriptor = {
63- get ( this : HTMLElement ) : string {
64- return String ( this . getAttribute ( name ) || '' )
65- } ,
66- set ( this : HTMLElement , newValue : string ) {
67- this . setAttribute ( name , newValue || '' )
68- }
69- }
7068 }
7169 Object . defineProperty ( instance , key , descriptor )
7270 if ( key in instance && ! instance . hasAttribute ( name ) ) {
0 commit comments