Skip to content

Commit 3729b63

Browse files
committed
fix
1 parent ea95475 commit 3729b63

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,9 +2041,8 @@ export const template_visitors = {
20412041
if (attribute.type === 'Attribute') {
20422042
if (attribute.name === 'xmlns' && !is_text_attribute(attribute)) {
20432043
dynamic_namespace = attribute.value;
2044-
} else {
2045-
attributes.push(attribute);
20462044
}
2045+
attributes.push(attribute);
20472046
} else if (attribute.type === 'SpreadAttribute') {
20482047
attributes.push(attribute);
20492048
} else if (attribute.type === 'ClassDirective') {

packages/svelte/src/internal/client/dom/blocks/svelte-element.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ export function element(anchor, get_tag, is_svg, render_fn, get_namespace) {
6969

7070
block(() => {
7171
const next_tag = get_tag() || null;
72-
const ns = get_namespace?.() || (is_svg || next_tag === 'svg' ? namespace_svg : null);
72+
const ns = get_namespace
73+
? get_namespace()
74+
: is_svg || next_tag === 'svg'
75+
? namespace_svg
76+
: null;
7377
// Assumption: Noone changes the namespace but not the tag (what would that even mean?)
7478
if (next_tag === tag) return;
7579

packages/svelte/tests/runtime-runes/samples/dynamic-element-dynamic-namespace/main.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<button onclick={() => {
77
tag = 'div';
8-
xmlns = 'http://www.w3.org/1999/xhtml';
8+
xmlns = null;
99
}}>change</button>
1010

1111
<!-- wrapper necessary or else jsdom says this is always an xhtml namespace -->

packages/svelte/types/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,10 +1539,10 @@ declare module 'svelte/compiler' {
15391539
tag: Expression;
15401540
metadata: {
15411541
/**
1542-
* `true`/`false` if this is definitely (not) an svg element.
1543-
* `null` means we can't know statically.
1542+
* `true` if this is an svg element. The boolean may not be accurate because
1543+
* the tag is dynamic, but we do our best to infer it from the template.
15441544
*/
1545-
svg: boolean | null;
1545+
svg: boolean;
15461546
scoped: boolean;
15471547
};
15481548
}

0 commit comments

Comments
 (0)