-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: collect all necessary setters of html elements (#11371)
When spreading attributes, the setters of the element are checked. If they contain the key in question, it's set via that setter. For certain setters on certain elements this didn't work because the element prototype was not HTMLElement, rather a descendant of that (for example HTMLDivElement), which meant that only the setters of the descendant, not the superclass were taken into account. This fixes that by walking up the prototype chain until we find the Element prototype. fixes #11179
- Loading branch information
1 parent
cd25065
commit eb7e32c
Showing
5 changed files
with
46 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"svelte": patch | ||
--- | ||
|
||
fix: collect all necessary setters of html elements when spreading attributes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/svelte/tests/runtime-runes/samples/attribute-spread-hidden/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
async test({ target, assert }) { | ||
const div = target.querySelector('div'); | ||
const btn = target.querySelector('button'); | ||
|
||
assert.equal(div?.hidden, true); | ||
|
||
await btn?.click(); | ||
assert.equal(div?.hidden, false); | ||
} | ||
}); |
15 changes: 15 additions & 0 deletions
15
packages/svelte/tests/runtime-runes/samples/attribute-spread-hidden/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<script> | ||
let hidden = $state(true); | ||
const restProps = { | ||
id: '123' | ||
} | ||
</script> | ||
|
||
<button onclick={() => hidden = !hidden}> | ||
toggle hidden | ||
</button> | ||
|
||
<div {...restProps} hidden={hidden}> | ||
hello world (with spread attrs) | ||
</div> |