Skip to content

Commit

Permalink
fix: Continue traversing a non-self-closing element's children (#12175)
Browse files Browse the repository at this point in the history
* add failing test

* continue to traverse children of `Element` types

* fix test

* changeset
  • Loading branch information
AdrianGonz97 authored May 1, 2024
1 parent 508d7c0 commit 32c0acc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/smart-donkeys-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-migrate': patch
---

fix: continue traversing the children of non-self-closing elements
1 change: 1 addition & 0 deletions packages/migrate/migrations/self-closing-tags/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export async function remove_self_closing_tags({ preprocess, parse }, source) {
SVGElements.includes(node.name) ||
!/^[a-z0-9_-]+$/.test(node.name)
) {
next();
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const tests = {
'<svelte:options namespace="foreign" /><foo />': '<svelte:options namespace="foreign" /><foo />',
'<script>console.log("<div />")</script>': '<script>console.log("<div />")</script>',
'<script lang="ts">let a: string = ""</script><div />':
'<script lang="ts">let a: string = ""</script><div></div>'
'<script lang="ts">let a: string = ""</script><div></div>',
'<div><i/></div>': '<div><i></i></div>'
};

for (const input in tests) {
Expand Down

0 comments on commit 32c0acc

Please sign in to comment.