[feat] skip custom element check if <svelte:element> uses under svg (#7869)

* add test

* skip custom element check if svelte element uses under svg
pull/7873/head
Yuichiro Yamashita 2 years ago committed by GitHub
parent 56bcec5ddd
commit 433460ec2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -806,7 +806,9 @@ export default class ElementWrapper extends Wrapper {
if (this.node.is_dynamic_element) {
// call attribute bindings for custom element if tag is custom element
const tag = this.node.tag_expr.manipulate(block);
const attr_update = b`
const attr_update = this.node.namespace === namespaces.svg
? b`${fn}(${this.var}, ${data});`
: b`
if (/-/.test(${tag})) {
@set_custom_element_data_map(${this.var}, ${data});
} else {

@ -48,8 +48,10 @@ function create_dynamic_element(ctx) {
append(svelte_element1, svelte_element0);
},
p(ctx, dirty) {
set_svg_attributes(svelte_element0, svelte_element0_data = get_spread_update(svelte_element0_levels, [{ xmlns: "http://www.w3.org/2000/svg" }]));
set_svg_attributes(svelte_element1, svelte_element1_data = get_spread_update(svelte_element1_levels, [{ xmlns: "http://www.w3.org/2000/svg" }]));
svelte_element0_data = get_spread_update(svelte_element0_levels, [{ xmlns: "http://www.w3.org/2000/svg" }]);
set_svg_attributes(svelte_element0, svelte_element0_data);
svelte_element1_data = get_spread_update(svelte_element1_levels, [{ xmlns: "http://www.w3.org/2000/svg" }]);
set_svg_attributes(svelte_element1, svelte_element1_data);
},
d(detaching) {
if (detaching) detach(svelte_element1);

@ -0,0 +1,10 @@
export default {
html: '<svg xmlns="http://www.w3.org/2000/svg"><path xmlns="http://www.w3.org/2000/svg"></path></svg>',
test({ assert, target }) {
const svg = target.querySelector('svg');
const rect = target.querySelector('path');
assert.equal(svg.namespaceURI, 'http://www.w3.org/2000/svg');
assert.equal(rect.namespaceURI, 'http://www.w3.org/2000/svg');
}
};

@ -0,0 +1,3 @@
<svelte:element this="svg" xmlns="http://www.w3.org/2000/svg">
<svelte:element this="path" xmlns="http://www.w3.org/2000/svg"></svelte:element>
</svelte:element>
Loading…
Cancel
Save