@@ -65,54 +65,74 @@ export class Attributes {
65
65
const expr = this . base . element . getAttribute ( ':class' )
66
66
if ( ! expr ) return
67
67
68
- const updatedClassNames = await this . base . _interpret ( expr , {
69
- base : this . initialState . classList ,
70
- isClass : true ,
71
- } )
72
-
73
- this . base . element . setAttribute ( 'class' , updatedClassNames )
68
+ try {
69
+ const updatedClassNames = await this . base . _interpret ( expr , {
70
+ base : this . initialState . classList ,
71
+ isClass : true ,
72
+ } )
73
+
74
+ this . base . element . setAttribute ( 'class' , updatedClassNames )
75
+ } catch ( error ) {
76
+ if ( ! this . base . isExists ( ) ) return
77
+ throw error
78
+ }
74
79
}
75
80
76
81
async evaluateText ( ) {
77
82
const textExpr = this . base . element . getAttribute ( ':text' )
78
83
if ( ! textExpr ) return
79
84
80
- const newText = await this . base . _interpret ( textExpr )
85
+ try {
86
+ const newText = await this . base . _interpret ( textExpr )
81
87
82
- if ( newText || newText == '' ) this . base . element . innerText = newText
88
+ if ( newText || newText == '' ) this . base . element . innerText = newText
89
+ } catch ( error ) {
90
+ if ( ! this . base . isExists ( ) ) return
91
+ throw error
92
+ }
83
93
}
84
94
85
95
async evaluateValue ( ) {
86
- const valueExpr = this . base . element . getAttribute ( ':value' )
96
+ try {
97
+ const valueExpr = this . base . element . getAttribute ( ':value' )
87
98
88
- if ( valueExpr ) {
89
- const newValue = await this . base . _interpret ( valueExpr )
99
+ if ( valueExpr ) {
100
+ const newValue = await this . base . _interpret ( valueExpr )
90
101
91
- if ( this . base . element . value !== newValue && newValue != null )
92
- this . base . element . value = newValue
93
- }
102
+ if ( this . base . element . value !== newValue && newValue != null )
103
+ this . base . element . value = newValue
104
+ }
94
105
95
- const checkedExpr = this . base . element . getAttribute ( ':checked' )
106
+ const checkedExpr = this . base . element . getAttribute ( ':checked' )
96
107
97
- if ( checkedExpr ) {
98
- const newValue = await this . base . _interpret ( checkedExpr )
108
+ if ( checkedExpr ) {
109
+ const newValue = await this . base . _interpret ( checkedExpr )
99
110
100
- if ( newValue ) this . base . element . checked = newValue
111
+ if ( newValue ) this . base . element . checked = newValue
112
+ }
113
+ } catch ( error ) {
114
+ if ( ! this . base . isExists ( ) ) return
115
+ throw error
101
116
}
102
117
}
103
118
104
119
async evaluateOtherAttributes ( ) {
105
- for ( const attr of this . dynamicAttributes ) {
106
- if ( Attributes . CUSTOM_ATTRIBUTES . includes ( attr ) ) continue
107
-
108
- const expr = this . base . element . getAttribute ( attr )
109
- if ( ! expr ) return
110
-
111
- const newValue = await this . base . _interpret ( expr )
112
- const nativeAttr = attr . slice ( 1 )
113
-
114
- if ( this . base . element [ nativeAttr ] !== newValue && newValue != null )
115
- this . base . element [ nativeAttr ] = newValue
120
+ try {
121
+ for ( const attr of this . dynamicAttributes ) {
122
+ if ( Attributes . CUSTOM_ATTRIBUTES . includes ( attr ) ) continue
123
+
124
+ const expr = this . base . element . getAttribute ( attr )
125
+ if ( ! expr ) return
126
+
127
+ const newValue = await this . base . _interpret ( expr )
128
+ const nativeAttr = attr . slice ( 1 )
129
+
130
+ if ( this . base . element [ nativeAttr ] !== newValue && newValue != null )
131
+ this . base . element [ nativeAttr ] = newValue
132
+ }
133
+ } catch ( error ) {
134
+ if ( ! this . base . isExists ( ) ) return
135
+ throw error
116
136
}
117
137
}
118
138
0 commit comments