Skip to content

Commit 3bce292

Browse files
committed
shuffle
1 parent 50a9ebc commit 3bce292

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,16 @@ export function RegularElement(node, context) {
161161

162162
if (
163163
node.name === 'input' &&
164-
node.attributes.some((attribute) => {
165-
return (
166-
attribute.type === 'SpreadAttribute' ||
167-
(attribute.type === 'Attribute' &&
164+
(has_spread ||
165+
bindings.has('value') ||
166+
bindings.has('checked') ||
167+
bindings.has('group') ||
168+
attributes.some(
169+
(attribute) =>
170+
attribute.type === 'Attribute' &&
168171
(attribute.name === 'value' || attribute.name === 'checked') &&
169-
!is_text_attribute(attribute)) ||
170-
(attribute.type === 'BindDirective' &&
171-
(attribute.name === 'group' ||
172-
attribute.name === 'checked' ||
173-
attribute.name === 'value'))
174-
);
175-
})
172+
!is_text_attribute(attribute)
173+
))
176174
) {
177175
context.state.init.push(b.stmt(b.call('$.remove_input_defaults', context.state.node)));
178176
}
@@ -190,11 +188,11 @@ export function RegularElement(node, context) {
190188
setup_select_synchronization(/** @type {AST.BindDirective} */ (bindings.get('value')), context);
191189
}
192190

193-
const node_id = context.state.node;
194-
195191
// Let bindings first, they can be used on attributes
196192
context.state.init.push(...lets);
197193

194+
const node_id = context.state.node;
195+
198196
// Then do attributes
199197
let is_attributes_reactive = false;
200198
if (node.metadata.has_spread) {
@@ -253,11 +251,6 @@ export function RegularElement(node, context) {
253251
}
254252
}
255253

256-
// Apply the src and loading attributes for <img> elements after the element is appended to the document
257-
if (node.name === 'img' && (has_spread || lookup.has('loading'))) {
258-
context.state.after_update.push(b.stmt(b.call('$.handle_lazy_img', node_id)));
259-
}
260-
261254
// class/style directives must be applied last since they could override class/style attributes
262255
build_class_directives(class_directives, node_id, context, is_attributes_reactive);
263256
build_style_directives(
@@ -268,6 +261,11 @@ export function RegularElement(node, context) {
268261
lookup.has('style') || node.metadata.has_spread
269262
);
270263

264+
// Apply the src and loading attributes for <img> elements after the element is appended to the document
265+
if (node.name === 'img' && (has_spread || lookup.has('loading'))) {
266+
context.state.after_update.push(b.stmt(b.call('$.handle_lazy_img', node_id)));
267+
}
268+
271269
if (
272270
is_load_error_element(node.name) &&
273271
(has_spread || has_use || lookup.has('onload') || lookup.has('onerror'))

0 commit comments

Comments
 (0)