@@ -83,7 +83,6 @@ export function RegularElement(node, context) {
83
83
const lets = [ ] ;
84
84
85
85
const is_custom_element = is_custom_element_node ( node ) ;
86
- let needs_content_reset = false ;
87
86
88
87
if ( is_custom_element ) {
89
88
// cloneNode is faster, but it does not instantiate the underlying class of the
@@ -93,13 +92,6 @@ export function RegularElement(node, context) {
93
92
metadata . context . template_needs_import_node = true ;
94
93
}
95
94
96
- // visit let directives first, to set state
97
- for ( const attribute of node . attributes ) {
98
- if ( attribute . type === 'LetDirective' ) {
99
- lets . push ( /** @type {ExpressionStatement } */ ( context . visit ( attribute ) ) ) ;
100
- }
101
- }
102
-
103
95
/** @type {Map<string, AST.Attribute> } */
104
96
const lookup = new Map ( ) ;
105
97
@@ -109,21 +101,15 @@ export function RegularElement(node, context) {
109
101
let has_spread = false ;
110
102
111
103
for ( const attribute of node . attributes ) {
112
- if ( attribute . type === 'Attribute' ) {
113
- lookup . set ( attribute . name , attribute ) ;
114
-
115
- if (
116
- ( attribute . name === 'value' || attribute . name === 'checked' ) &&
117
- ! is_text_attribute ( attribute )
118
- ) {
119
- needs_content_reset = true ;
120
- }
121
- } else if ( attribute . type === 'SpreadAttribute' ) {
104
+ if ( attribute . type === 'SpreadAttribute' ) {
122
105
has_spread = true ;
123
- }
124
-
125
- if ( attribute . type === 'BindDirective' ) {
106
+ } else if ( attribute . type === 'Attribute' ) {
107
+ lookup . set ( attribute . name , attribute ) ;
108
+ } else if ( attribute . type === 'BindDirective' ) {
126
109
bindings . set ( attribute . name , attribute ) ;
110
+ } else if ( attribute . type === 'LetDirective' ) {
111
+ // visit let directives before everything else, to set state
112
+ lets . push ( /** @type {ExpressionStatement } */ ( context . visit ( attribute ) ) ) ;
127
113
}
128
114
}
129
115
@@ -178,8 +164,13 @@ export function RegularElement(node, context) {
178
164
context . state . init . push ( b . stmt ( b . call ( '$.remove_input_defaults' , context . state . node ) ) ) ;
179
165
}
180
166
181
- if ( node . name === 'textarea' && ( has_spread || bindings . has ( 'value' ) || needs_content_reset ) ) {
182
- context . state . init . push ( b . stmt ( b . call ( '$.remove_textarea_child' , context . state . node ) ) ) ;
167
+ if ( node . name === 'textarea' ) {
168
+ const attribute = lookup . get ( 'value' ) ?? lookup . get ( 'checked' ) ;
169
+ const needs_content_reset = attribute && ! is_text_attribute ( attribute ) ;
170
+
171
+ if ( has_spread || bindings . has ( 'value' ) || needs_content_reset ) {
172
+ context . state . init . push ( b . stmt ( b . call ( '$.remove_textarea_child' , context . state . node ) ) ) ;
173
+ }
183
174
}
184
175
185
176
if ( node . name === 'select' && bindings . has ( 'value' ) ) {
0 commit comments