Skip to content

Commit d0b41ee

Browse files
chore: tidy up walk logic in enhanced-img (#13600)
Co-authored-by: Ben McCann <[email protected]>
1 parent 770a7eb commit d0b41ee

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

Diff for: packages/enhanced-img/src/preprocessor.js

+14-23
Original file line numberDiff line numberDiff line change
@@ -127,31 +127,22 @@ export function image(opts) {
127127
*/
128128
const pending_ast_updates = [];
129129

130-
walk(
131-
/** @type {import('svelte/compiler').AST.Root} */ (ast),
132-
{},
133-
{
134-
_(_, { next }) {
135-
next();
136-
},
137-
/** @param {import('svelte/compiler').AST.RegularElement} node */
138-
// @ts-ignore
139-
RegularElement(node, { next }) {
140-
if ('name' in node && node.name === 'enhanced:img') {
141-
// Compare node tag match
142-
const src = get_attr_value(node, 'src');
143-
144-
if (!src || typeof src === 'boolean') return;
145-
146-
pending_ast_updates.push(update_element(node, src));
147-
148-
return;
149-
}
150-
151-
next();
130+
walk(/** @type {import('svelte/compiler').AST.TemplateNode} */ (ast), null, {
131+
RegularElement(node, { next }) {
132+
if ('name' in node && node.name === 'enhanced:img') {
133+
// Compare node tag match
134+
const src = get_attr_value(node, 'src');
135+
136+
if (!src || typeof src === 'boolean') return;
137+
138+
pending_ast_updates.push(update_element(node, src));
139+
140+
return;
152141
}
142+
143+
next();
153144
}
154-
);
145+
});
155146

156147
await Promise.all(pending_ast_updates);
157148

0 commit comments

Comments
 (0)