mirror of https://github.com/sveltejs/svelte
feat: apply inert to outroing elements (#8628)
that way they are invisible to assistive technology and can't be interacted with, which makes sense since the element is already "dead" and only transitioning out at this point closes #8445pull/8654/head
parent
df361a2d6d
commit
734cc19846
@ -0,0 +1,28 @@
|
||||
export default {
|
||||
async test({ assert, component, target, raf }) {
|
||||
// jsdom doesn't set the inert attribute, and the transition checks if it exists, so set it manually to trigger the inert logic
|
||||
target.querySelector('button.a').inert = false;
|
||||
target.querySelector('button.b').inert = false;
|
||||
|
||||
// check and abort halfway through the outro transition
|
||||
component.visible = false;
|
||||
raf.tick(50);
|
||||
assert.strictEqual(target.querySelector('button.a').inert, true);
|
||||
assert.strictEqual(target.querySelector('button.b').inert, true);
|
||||
|
||||
component.visible = true;
|
||||
assert.strictEqual(target.querySelector('button.a').inert, false);
|
||||
assert.strictEqual(target.querySelector('button.b').inert, false);
|
||||
|
||||
// let it transition out completely and then back in
|
||||
component.visible = false;
|
||||
raf.tick(101);
|
||||
component.visible = true;
|
||||
raf.tick(50);
|
||||
assert.strictEqual(target.querySelector('button.a').inert, false);
|
||||
assert.strictEqual(target.querySelector('button.b').inert, false);
|
||||
raf.tick(51);
|
||||
assert.strictEqual(target.querySelector('button.a').inert, false);
|
||||
assert.strictEqual(target.querySelector('button.b').inert, false);
|
||||
}
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
export let visible = true;
|
||||
|
||||
function slide(_, params) {
|
||||
return params;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<button class="a" transition:slide={{ duration: 100 }}>
|
||||
foo
|
||||
</button>
|
||||
<button class="b" out:slide={{ duration: 100 }}>
|
||||
bar
|
||||
</button>
|
||||
{/if}
|
Loading…
Reference in new issue