Skip to content

Commit 32ee6ef

Browse files
committed
fix handler SSRed into attribute
1 parent 95d4ec8 commit 32ee6ef

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export function spread_attributes(attrs, css_hash, classes, styles, flags = 0) {
184184
for (name in attrs) {
185185
// omit functions, internal svelte properties and invalid attribute names
186186
if (typeof attrs[name] === 'function') continue;
187+
if (name[0] === 'o' && name[1] === 'n' && typeof attrs[name] === 'object') continue;
187188
if (name[0] === '$' && name[1] === '$') continue; // faster than name.startsWith('$$')
188189
if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
189190

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
test({ assert, target }) {
5+
assert.htmlEqual(
6+
target.innerHTML,
7+
`<button>a</button><button>b</button><button>c</button><button>d</button>`
8+
);
9+
}
10+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<script>
2+
const props = $props();
3+
</script>
4+
5+
<button onclick={props.onclick}>c</button>
6+
<button {...props}>d</button>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script>
2+
import Child from "./child.svelte";
3+
4+
const onclick = {
5+
handleEvent() {}
6+
};
7+
</script>
8+
9+
<button {onclick}>a</button>
10+
<button {...{onclick}}>b</button>
11+
12+
<Child {onclick} />

0 commit comments

Comments
 (0)