-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: infer svg
namespace correctly
#10027
Conversation
🦋 Changeset detectedLatest commit: eb8475f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@navorite is attempting to deploy a commit to the Svelte Team on Vercel. A member of the Team first needs to authorize it. |
parent_node.type === 'SnippetBlock' || | ||
parent_node.type === 'IfBlock' || | ||
parent_node.type === 'EachBlock' || | ||
parent_node.type === 'AwaitBlock') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parent_node.type === 'SnippetBlock' || | |
parent_node.type === 'IfBlock' || | |
parent_node.type === 'EachBlock' || | |
parent_node.type === 'AwaitBlock') | |
parent_node.type === 'SnippetBlock') |
@@ -222,7 +225,7 @@ export function infer_namespace(namespace, parent, nodes, path) { | |||
only_svg = false; | |||
break; | |||
} | |||
} else if (node.type !== 'Text' || node.data.trim() !== '') { | |||
} else if (node.type !== 'ConstTag' && (node.type !== 'Text' || node.data.trim() !== '')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for tackling this, but this is not quite right. We need to keep the check above as-is, and instead need to check that if we discover if/await/each blocks while traversing the nodes here, that the top level children of those are all svg elements (basically this loop needs to become recursive). Also, could you add a test case for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I realized that is the correct approach while trying to fix it, that's why I kept it a draft. I will add a test case shortly and maybe implement this.
[WIP]: closes #10025, the following cases where it would infer the namespace as
html
are now fixed:{@const}
tag inside the markupEdit: I think there might be a better approach to this, as this wouldn't solve a case like this:
Svelte 5 rewrite
Please note that the Svelte codebase is currently being rewritten for Svelte 5. Changes should target Svelte 5, which lives on the default branch (
main
).If your PR concerns Svelte 4 (including updates to svelte.dev.docs), please ensure the base branch is
svelte-4
and notmain
.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint