-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0520a10
commit be67e12
Showing
3 changed files
with
33 additions
and
9 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
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 |
---|---|---|
@@ -1,8 +1,24 @@ | ||
export default { | ||
html: '', | ||
|
||
test({ assert, component, target, window }) { | ||
async test({ assert, component, target, window }) { | ||
component.visible = true; | ||
assert.equal(target.querySelector('input'), window.document.activeElement); | ||
const input = target.querySelector('input'); | ||
async function dispatchEvent(value) { | ||
input.value = value; | ||
const inputEvent = new window.InputEvent("input"); | ||
await input.dispatchEvent(inputEvent); | ||
} | ||
|
||
assert.equal(window.document.activeElement.getAttribute('title'), 'text'); | ||
|
||
await dispatchEvent('dynamic'); | ||
assert.equal(window.document.activeElement.getAttribute('title'), 'dynamic'); | ||
|
||
await dispatchEvent('bound'); | ||
assert.equal(window.document.activeElement.getAttribute('title'), 'bound'); | ||
|
||
await dispatchEvent('fn'); | ||
assert.equal(window.document.activeElement.getAttribute('title'), 'fn'); | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,8 +1,16 @@ | ||
<script> | ||
export let visible = false; | ||
let input; | ||
let autofocus = true; | ||
let active = "text"; | ||
</script> | ||
|
||
{#if visible} | ||
<input bind:this={input} autofocus> | ||
{/if} | ||
<input title="input" bind:value={active} /> | ||
|
||
{#if active === "text"} | ||
<input title={active} autofocus /> | ||
{:else if active === "dynamic"} | ||
<input title={active} {autofocus} /> | ||
{:else if active === "bound"} | ||
<input title={active} autofocus={autofocus} /> | ||
{:else if active === "fn"} | ||
<input title={active} autofocus={() => true} /> | ||
{/if} |