@@ -56,6 +56,7 @@ export class Attributes {
56
56
await this . evaluateClass ( )
57
57
await this . evaluateText ( )
58
58
await this . evaluateValue ( )
59
+ await this . evaluateChecked ( )
59
60
60
61
for ( const attr of this . dynamicAttributes ) {
61
62
if ( Attributes . CUSTOM_ATTRIBUTES . includes ( attr ) ) continue
@@ -70,7 +71,8 @@ export class Attributes {
70
71
if ( attr === ':parent' ) this . evaluateParent ( )
71
72
else if ( attr === ':class' ) await this . evaluateClass ( )
72
73
else if ( attr === ':text' ) await this . evaluateText ( )
73
- else if ( [ ':value' , ':checked' ] . includes ( attr ) ) await this . evaluateValue ( )
74
+ else if ( attr === ':value' ) await this . evaluateValue ( )
75
+ else if ( attr === ':checked' ) await this . evaluateChecked ( )
74
76
else if ( attr === ':each' ) await this . evaluateEach ( )
75
77
else {
76
78
if ( ! this . dynamicAttributes . includes ( attr ) )
@@ -108,32 +110,36 @@ export class Attributes {
108
110
try {
109
111
const newText = await this . base . _interpret ( textExpr )
110
112
111
- if ( newText || newText == '' ) this . base . element . innerText = newText
113
+ if ( newText || newText == '' ) this . base . element . textContent = newText
112
114
} catch ( error ) {
113
115
this . _handleError ( ':text' , error )
114
116
}
115
117
}
116
118
117
119
async evaluateValue ( ) {
120
+ const valueExpr = this . base . element . getAttribute ( ':value' )
121
+ if ( ! valueExpr ) return
118
122
try {
119
- const valueExpr = this . base . element . getAttribute ( ':value' )
123
+ const newValue = await this . base . _interpret ( valueExpr )
120
124
121
- if ( valueExpr ) {
122
- const newValue = await this . base . _interpret ( valueExpr )
123
-
124
- if ( this . base . element . value !== newValue && newValue != null )
125
- this . base . element . value = newValue
126
- }
125
+ if ( this . base . element . value !== newValue && newValue != null )
126
+ this . base . element . value = newValue
127
+ } catch ( error ) {
128
+ this . _handleError ( ': value' , error )
129
+ }
130
+ }
127
131
128
- const checkedExpr = this . base . element . getAttribute ( ':checked' )
132
+ async evaluateChecked ( ) {
133
+ const checkedExpr = this . base . element . getAttribute ( ':checked' )
134
+ if ( ! checkedExpr ) return
129
135
130
- if ( checkedExpr ) {
131
- const newValue = await this . base . _interpret ( checkedExpr )
136
+ try {
137
+ const isChecked = await this . base . _interpret ( checkedExpr )
132
138
133
- if ( newValue ) this . base . element . checked = newValue
134
- }
139
+ if ( this . base . element . checked !== isChecked && isChecked != null )
140
+ this . base . element . checked = isChecked
135
141
} catch ( error ) {
136
- this . _handleError ( ':value ' , error )
142
+ this . _handleError ( ':checked ' , error )
137
143
}
138
144
}
139
145
0 commit comments