Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sorting in Svelte :else blocks #79

Merged
merged 1 commit into from May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/index.js
Expand Up @@ -432,6 +432,12 @@ function transformSvelte(ast, { env, changes }) {
for (let child of ast.children ?? []) {
transformSvelte(child, { env, changes })
}

if (ast.type === 'IfBlock') {
for (let child of ast.else?.children ?? []) {
transformSvelte(child, { env, changes })
}
}
}

// https://lihautan.com/manipulating-ast-with-javascript/
Expand Down
1 change: 1 addition & 0 deletions tests/test.js
Expand Up @@ -165,6 +165,7 @@ let tests = {
t`<div class={\`${no}\${someVar}${no}\`} />`,
t`<div class="${yes} {\`${yes}\`}" />`,
t`<div let:class={clazz} class="${yes} {clazz}" />`,
t`{#if something} <div class="${yes}" /> {:else} <div class="${yes}" /> {/if}`,
[
`<div class="sm:block uppercase flex{someVar}" />`,
`<div class="uppercase sm:block flex{someVar}" />`,
Expand Down