Merge pull request #3403 from davebrent/gh-3321

Fix namespace for svg elements inside slots
pull/3405/head
Rich Harris 5 years ago committed by GitHub
commit 626b8335c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -84,7 +84,7 @@ function get_namespace(parent: Element, element: Element, explicit_namespace: st
: null);
}
if (element.name.toLowerCase() === 'svg') return namespaces.svg;
if (svg.test(element.name.toLowerCase())) return namespaces.svg;
if (parent_element.name.toLowerCase() === 'foreignobject') return null;
return parent_element.namespace;

@ -0,0 +1,3 @@
<svg>
<slot />
</svg>

After

Width:  |  Height:  |  Size: 23 B

@ -0,0 +1,17 @@
export default {
html: `
<div>
<svg>
<line x1="0" y1="0" x2="100" y2="100" />
</svg>
</div>
`,
test({ assert, target }) {
const div = target.querySelector('div');
assert.equal(div.namespaceURI, 'http://www.w3.org/1999/xhtml');
const line = target.querySelector('line');
assert.equal(line.namespaceURI, 'http://www.w3.org/2000/svg');
}
};

@ -0,0 +1,9 @@
<script>
import Widget from './Widget.svelte'
</script>
<div>
<Widget>
<line x1="0" y1="0" x2="100" y2="100" />
</Widget>
</div>
Loading…
Cancel
Save