Skip to content

Commit b4863d8

Browse files
committed
fix(preprocess-*): should call zimmerframe next to exhust AST
1 parent 9dfcc13 commit b4863d8

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

.changeset/gorgeous-humans-fry.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@svelte-put/preprocess-external-link': patch
3+
'@svelte-put/preprocess-inline-svg': patch
4+
'@svelte-put/preprocess-auto-slug': patch
5+
---
6+
7+
should exhaust the AST walk (invoking `next` from zimmerframe)

packages/preprocess-auto-slug/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export function autoSlug(input = {}) {
5555
const slugger = new BananaSlug();
5656

5757
walk(/** @type {import('svelte/compiler').ElementLike} */(/** @type {unknown} */(ast.fragment)), null, {
58-
RegularElement(node) {
58+
RegularElement(node, { next }) {
5959
if (
6060
!options.tags.includes(node.name) ||
6161
!node.fragment.nodes?.length
62-
) return node;
62+
) return next();
6363

6464
let id = '';
6565
// find the id attribute (or as specified in user config), if any

packages/preprocess-external-link/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export function externalLink(config) {
5151
),
5252
null,
5353
{
54-
RegularElement(node) {
55-
if (node.name !== 'a') return;
54+
RegularElement(node, { next }) {
55+
if (node.name !== 'a') return next();
5656

5757
const attributes = /** @type {import('svelte/compiler').Attribute[]} */ (
5858
node.attributes.filter((attr) => attr.type === 'Attribute')

packages/preprocess-inline-svg/src/internals.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ export function transform(code, filename, sources, config) {
160160
const ast = parseSvelteMarkup(code, { filename, modern: true });
161161

162162
walk(/** @type {import('svelte/compiler').ElementLike} */(/** @type {unknown} */(ast.fragment)), null, {
163-
RegularElement(node) {
164-
if (node.name !== 'svg') return;
163+
RegularElement(node, { next }) {
164+
if (node.name !== 'svg') return next();
165165
let options = local;
166166
let inlineSrc = getAttribute(code, node, inlineSrcAttributeName);
167167
let svgSource = findSvgSrc(filename, options.directories, inlineSrc);

0 commit comments

Comments
 (0)