mirror of https://github.com/sveltejs/svelte
fix: take custom attribute name into account when reflecting property (#9140)
fixes #9134pull/9144/head
parent
3c9e661f4a
commit
bd64f07e98
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: take custom attribute name into account when reflecting property
|
@ -0,0 +1,23 @@
|
|||||||
|
<svelte:options
|
||||||
|
customElement={{
|
||||||
|
tag: 'custom-element',
|
||||||
|
props: {
|
||||||
|
expanded: { reflect: true, type: 'Boolean', attribute: 'aria-expanded' }
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export let expanded = false;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button on:click={() => (expanded = !expanded)}>Toggle</button>
|
||||||
|
<div class:hidden={!expanded}>Hidden Text</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
@ -0,0 +1,19 @@
|
|||||||
|
import * as assert from 'assert.js';
|
||||||
|
import { tick } from 'svelte';
|
||||||
|
import './main.svelte';
|
||||||
|
|
||||||
|
export default async function (target) {
|
||||||
|
const element = document.createElement('custom-element');
|
||||||
|
target.appendChild(element);
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
const el = target.querySelector('custom-element');
|
||||||
|
el.shadowRoot.querySelector('button').click();
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
assert.equal(el.getAttribute('aria-expanded'), '');
|
||||||
|
el.shadowRoot.querySelector('button').click();
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
assert.equal(el.getAttribute('aria-expanded'), null);
|
||||||
|
}
|
Loading…
Reference in new issue