Skip to content

Commit ef640c3

Browse files
authored
fix: render attributes during SSR regardless of case (#14492)
fixes part of #14479
1 parent 83cec2f commit ef640c3

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

.changeset/proud-crews-itch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: render attributes during SSR regardless of case

packages/svelte/src/internal/server/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,13 @@ export function spread_attributes(attrs, classes, styles, flags = 0) {
222222
if (name[0] === '$' && name[1] === '$') continue; // faster than name.startsWith('$$')
223223
if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
224224

225+
var value = attrs[name];
226+
225227
if (lowercase) {
226228
name = name.toLowerCase();
227229
}
228230

229-
attr_str += attr(name, attrs[name], is_html && is_boolean_attribute(name));
231+
attr_str += attr(name, value, is_html && is_boolean_attribute(name));
230232
}
231233

232234
return attr_str;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
mode: ['hydrate'],
5+
6+
test({ assert, target, hydrate }) {
7+
const svg = target.querySelector('svg');
8+
const circle = target.querySelector('circle');
9+
10+
assert.equal(svg?.getAttribute('viewBox'), '0 0 1000 1000');
11+
assert.equal(svg?.namespaceURI, 'http://www.w3.org/2000/svg');
12+
assert.equal(circle?.namespaceURI, 'http://www.w3.org/2000/svg');
13+
14+
hydrate();
15+
16+
assert.equal(svg?.getAttribute('viewBox'), '0 0 1000 1000');
17+
assert.equal(svg?.namespaceURI, 'http://www.w3.org/2000/svg');
18+
assert.equal(circle?.namespaceURI, 'http://www.w3.org/2000/svg');
19+
}
20+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>
2+
let props = {
3+
height: '100px',
4+
width: '100px',
5+
viewBox: '0 0 1000 1000'
6+
};
7+
</script>
8+
9+
<svelte:element this={'svg'} {...props}>
10+
<circle cx="500" cy="500" r="500"></circle>
11+
</svelte:element>

0 commit comments

Comments
 (0)