mirror of https://github.com/sveltejs/svelte
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 #11179pull/11381/head
parent
cd2506535f
commit
eb7e32c168
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"svelte": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: collect all necessary setters of html elements when spreading attributes
|
@ -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);
|
||||||
|
}
|
||||||
|
});
|
@ -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>
|
Loading…
Reference in new issue