diff --git a/.changeset/proud-crews-itch.md b/.changeset/proud-crews-itch.md new file mode 100644 index 0000000000..fd4657c588 --- /dev/null +++ b/.changeset/proud-crews-itch.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: render attributes during SSR regardless of case diff --git a/packages/svelte/src/internal/server/index.js b/packages/svelte/src/internal/server/index.js index 615a49fbd4..b944c602b8 100644 --- a/packages/svelte/src/internal/server/index.js +++ b/packages/svelte/src/internal/server/index.js @@ -222,11 +222,13 @@ export function spread_attributes(attrs, classes, styles, flags = 0) { if (name[0] === '$' && name[1] === '$') continue; // faster than name.startsWith('$$') if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue; + var value = attrs[name]; + if (lowercase) { name = name.toLowerCase(); } - attr_str += attr(name, attrs[name], is_html && is_boolean_attribute(name)); + attr_str += attr(name, value, is_html && is_boolean_attribute(name)); } return attr_str; diff --git a/packages/svelte/tests/runtime-runes/samples/dynamic-element-svg/_config.js b/packages/svelte/tests/runtime-runes/samples/dynamic-element-svg/_config.js new file mode 100644 index 0000000000..b7c96dc8bd --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/dynamic-element-svg/_config.js @@ -0,0 +1,20 @@ +import { test } from '../../test'; + +export default test({ + mode: ['hydrate'], + + test({ assert, target, hydrate }) { + const svg = target.querySelector('svg'); + const circle = target.querySelector('circle'); + + assert.equal(svg?.getAttribute('viewBox'), '0 0 1000 1000'); + assert.equal(svg?.namespaceURI, 'http://www.w3.org/2000/svg'); + assert.equal(circle?.namespaceURI, 'http://www.w3.org/2000/svg'); + + hydrate(); + + assert.equal(svg?.getAttribute('viewBox'), '0 0 1000 1000'); + assert.equal(svg?.namespaceURI, 'http://www.w3.org/2000/svg'); + assert.equal(circle?.namespaceURI, 'http://www.w3.org/2000/svg'); + } +}); diff --git a/packages/svelte/tests/runtime-runes/samples/dynamic-element-svg/main.svelte b/packages/svelte/tests/runtime-runes/samples/dynamic-element-svg/main.svelte new file mode 100644 index 0000000000..b7e53714ac --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/dynamic-element-svg/main.svelte @@ -0,0 +1,11 @@ + + + + +