Skip to content

Conversation

@trueadm
Copy link
Contributor

@trueadm trueadm commented Dec 12, 2024

Fixes #14671.

@changeset-bot
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

@github-actions
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

3 participants