-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly infer
<a>
tag namespace (#14134)
`<a>` tags are valid in both the SVG and HTML namespace. If there's no parent, we therefore have to look downwards to see if it's the parent of a SVG or HTML element. fixes #7807 fixes #13793
- Loading branch information
1 parent
8de5605
commit 551284c
Showing
10 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: correctly infer `<a>` tag namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/svelte/tests/runtime-runes/samples/html-namespace-infer-a-tag/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
html: ` | ||
<div><a><span>Hello</span></a></div> | ||
<div><a><span>Hello</span></a></div> | ||
<div><a><span>Hello</span></a></div> | ||
`, | ||
test({ assert, target }) { | ||
const div = target.querySelectorAll('div'); | ||
const a = target.querySelectorAll('a'); | ||
const span = target.querySelectorAll('span'); | ||
|
||
for (const element of div) { | ||
assert.equal(element.namespaceURI, 'http://www.w3.org/1999/xhtml'); | ||
} | ||
|
||
for (const element of a) { | ||
assert.equal(element.namespaceURI, 'http://www.w3.org/1999/xhtml'); | ||
} | ||
|
||
for (const element of span) { | ||
assert.equal(element.namespaceURI, 'http://www.w3.org/1999/xhtml'); | ||
} | ||
} | ||
}); |
7 changes: 7 additions & 0 deletions
7
packages/svelte/tests/runtime-runes/samples/html-namespace-infer-a-tag/div.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
let { children } = $props(); | ||
</script> | ||
|
||
<div> | ||
{@render children()} | ||
</div> |
24 changes: 24 additions & 0 deletions
24
packages/svelte/tests/runtime-runes/samples/html-namespace-infer-a-tag/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script> | ||
import Div from './div.svelte'; | ||
</script> | ||
|
||
<div> | ||
<a> | ||
<span>Hello</span> | ||
</a> | ||
</div> | ||
|
||
<div> | ||
{#snippet test()} | ||
<a> | ||
<span>Hello</span> | ||
</a> | ||
{/snippet} | ||
{@render test()} | ||
</div> | ||
|
||
<Div> | ||
<a> | ||
<span>Hello</span> | ||
</a> | ||
</Div> |
26 changes: 26 additions & 0 deletions
26
packages/svelte/tests/runtime-runes/samples/svg-namespace-infer-a-tag/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
html: ` | ||
<svg><a><text>Hello</text></a></svg> | ||
<svg><a><text>Hello</text></a></svg> | ||
<svg><a><text>Hello</text></a></svg> | ||
`, | ||
test({ assert, target }) { | ||
const svg = target.querySelectorAll('svg'); | ||
const a = target.querySelectorAll('a'); | ||
const text = target.querySelectorAll('text'); | ||
|
||
for (const element of svg) { | ||
assert.equal(element.namespaceURI, 'http://www.w3.org/2000/svg'); | ||
} | ||
|
||
for (const element of a) { | ||
assert.equal(element.namespaceURI, 'http://www.w3.org/2000/svg'); | ||
} | ||
|
||
for (const element of text) { | ||
assert.equal(element.namespaceURI, 'http://www.w3.org/2000/svg'); | ||
} | ||
} | ||
}); |
24 changes: 24 additions & 0 deletions
24
packages/svelte/tests/runtime-runes/samples/svg-namespace-infer-a-tag/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script> | ||
import Svg from './svg.svelte'; | ||
</script> | ||
|
||
<svg> | ||
<a> | ||
<text>Hello</text> | ||
</a> | ||
</svg> | ||
|
||
<svg> | ||
{#snippet test()} | ||
<a> | ||
<text>Hello</text> | ||
</a> | ||
{/snippet} | ||
{@render test()} | ||
</svg> | ||
|
||
<Svg> | ||
<a> | ||
<text>Hello</text> | ||
</a> | ||
</Svg> |
7 changes: 7 additions & 0 deletions
7
packages/svelte/tests/runtime-runes/samples/svg-namespace-infer-a-tag/svg.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
let { children } = $props(); | ||
</script> | ||
|
||
<svg> | ||
{@render children()} | ||
</svg> |