Skip to content

Commit 626b833

Browse files
authored
Merge pull request #3403 from davebrent/gh-3321
Fix namespace for svg elements inside slots
2 parents 4f26363 + 9c0db84 commit 626b833

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

src/compiler/compile/nodes/Element.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function get_namespace(parent: Element, element: Element, explicit_namespace: st
8484
: null);
8585
}
8686

87-
if (element.name.toLowerCase() === 'svg') return namespaces.svg;
87+
if (svg.test(element.name.toLowerCase())) return namespaces.svg;
8888
if (parent_element.name.toLowerCase() === 'foreignobject') return null;
8989

9090
return parent_element.namespace;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<svg>
2+
<slot />
3+
</svg>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export default {
2+
html: `
3+
<div>
4+
<svg>
5+
<line x1="0" y1="0" x2="100" y2="100" />
6+
</svg>
7+
</div>
8+
`,
9+
10+
test({ assert, target }) {
11+
const div = target.querySelector('div');
12+
assert.equal(div.namespaceURI, 'http://www.w3.org/1999/xhtml');
13+
14+
const line = target.querySelector('line');
15+
assert.equal(line.namespaceURI, 'http://www.w3.org/2000/svg');
16+
}
17+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script>
2+
import Widget from './Widget.svelte'
3+
</script>
4+
5+
<div>
6+
<Widget>
7+
<line x1="0" y1="0" x2="100" y2="100" />
8+
</Widget>
9+
</div>

0 commit comments

Comments
 (0)