mirror of https://github.com/sveltejs/svelte
Feat: Add read-only binding focused (#11271)
* Feat: Add readonly binding focused * prettier * simplify test * revert * simplify implementation * changeset --------- Co-authored-by: Rich Harris <rich.harris@vercel.com> Co-authored-by: Rich Harris <hello@rich-harris.dev>pull/11260/head
parent
b91a67ba68
commit
11c7cd5495
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
feat: add read-only `bind:focused`
|
@ -0,0 +1,19 @@
|
||||
import { flushSync } from 'svelte';
|
||||
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, component, target, window }) {
|
||||
const [in1, in2] = target.querySelectorAll('input');
|
||||
|
||||
flushSync(() => in1.focus());
|
||||
assert.equal(window.document.activeElement, in1);
|
||||
assert.equal(component.a, true);
|
||||
assert.equal(component.b, false);
|
||||
|
||||
flushSync(() => in2.focus());
|
||||
assert.equal(window.document.activeElement, in2);
|
||||
assert.equal(component.a, false);
|
||||
assert.equal(component.b, true);
|
||||
}
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
export let a;
|
||||
export let b;
|
||||
</script>
|
||||
|
||||
<input bind:focused={a} />
|
||||
<input bind:focused={b} />
|
Loading…
Reference in new issue