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: ensure if block paths retain correct template namespacing #14685

Merged
merged 5 commits into from
Dec 12, 2024

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Dec 12, 2024

Fixes #14671.

Copy link

changeset-bot bot commented Dec 12, 2024

🦋 Changeset detected

Latest commit: e3d9055

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

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

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@14685

@Rich-Harris
Copy link
Member

This doesn't seem like the right fix. For one thing it very much does apply to other blocks. Really though I don't think we should be reaching into the fragment to ascertain its namespace so that we can tell the Fragment visitor which namespace it should be in — that logic should just live in the Fragment visitor, surely?

As it happens, the Fragment visitor does have some logic for this — infer_namespace — but it seems buggy. That's presumably where we need to apply the fix.

I'm pretty sure a fragment shouldn't need to care about namespace unless it contains elements. The only time it should need to care about parent namespace is in ambiguous cases (an <a>, <title> element could be either HTML or SVG — I think these are the only ones we need to worry about) in which case inheriting from parent (falling back to HTML if no parent element exists) seems like the obvious solution.

@trueadm
Copy link
Contributor Author

trueadm commented Dec 12, 2024

This doesn't seem like the right fix. For one thing it very much does apply to other blocks. Really though I don't think we should be reaching into the fragment to ascertain its namespace so that we can tell the Fragment visitor which namespace it should be in — that logic should just live in the Fragment visitor, surely?

As it happens, the Fragment visitor does have some logic for this — infer_namespace — but it seems buggy. That's presumably where we need to apply the fix.

I'm pretty sure a fragment shouldn't need to care about namespace unless it contains elements. The only time it should need to care about parent namespace is in ambiguous cases (an <a>, <title> element could be either HTML or SVG — I think these are the only ones we need to worry about) in which case inheriting from parent (falling back to HTML if no parent element exists) seems like the obvious solution.

I completely missed infer_namespaces. I moved my logic into there and now. I didn't alter the existing logic but maybe it does need a refactor like you suggested, however I'm a bit worried about the implications it might have as there doesn't seem to be much testing around it all.

@Rich-Harris
Copy link
Member

yeah, we can leave the refactor for when we're less busy

@trueadm trueadm merged commit 2e0dcd7 into main Dec 12, 2024
11 checks passed
@trueadm trueadm deleted the if-block-namespacing branch December 12, 2024 20:09
@github-actions github-actions bot mentioned this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SVG render issues within #if blocks
2 participants