-
-
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.
fix(5018): add tests to check if text is updated once
- Loading branch information
1 parent
f50e7cf
commit 06b3ba6
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
test/runtime/samples/component-event-handler-contenteditable/_config.js
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default { | ||
html: ` | ||
<div contenteditable=""></div> | ||
`, | ||
|
||
async test({ assert, component, target, window }) { | ||
const div = target.querySelector('div'); | ||
const text = window.document.createTextNode('a'); | ||
div.insertBefore(text, null); | ||
const event = new window.InputEvent('input'); | ||
await div.dispatchEvent(event); | ||
|
||
assert.equal(div.textContent, 'a'); | ||
} | ||
}; |
6 changes: 6 additions & 0 deletions
6
test/runtime/samples/component-event-handler-contenteditable/main.svelte
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script> | ||
let text = ''; | ||
const updater = (event) => {text = event.target.textContent} | ||
</script> | ||
|
||
<div contenteditable on:input={updater}>{text}</div> |