Skip to content

Commit

Permalink
chore(preprocess-inline-svg): return undefined during zimmerframe wal…
Browse files Browse the repository at this point in the history
…king as no AST was transformed
  • Loading branch information
vnphanquang committed May 18, 2024
1 parent 859f587 commit 38c09f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-carpets-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svelte-put/preprocess-inline-svg": patch
---

not necessary to return if not transfer in zimmerframe walk methods
7 changes: 3 additions & 4 deletions packages/preprocess-inline-svg/src/internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,9 @@ export function transform(code, filename, sources, config) {
walk(ast.fragment, null, {
/**
* @param {import('svelte/compiler').RegularElement} node
* @returns {import('svelte/compiler').RegularElement}
*/
RegularElement(node) {
if (node.name !== 'svg') return node;
if (node.name !== 'svg') return;
let options = local;
let inlineSrc = getAttribute(code, node, inlineSrcAttributeName);
let svgSource = findSvgSrc(filename, options.directories, inlineSrc);
Expand All @@ -178,7 +177,7 @@ export function transform(code, filename, sources, config) {
}
}

if (!inlineSrc) return node;
if (!inlineSrc) return;
if (!svgSource) {
throw new Error(
`\n@svelte-put/preprocess-inline-svg: cannot find svg source for ${inlineSrc} at ${filename}`,
Expand Down Expand Up @@ -221,7 +220,7 @@ export function transform(code, filename, sources, config) {
});
s.update(insertIndex, node.end, `>${content}</svg>`);

return node;
return;
},
});

Expand Down

0 comments on commit 38c09f1

Please sign in to comment.