Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(5018): compare wholeText instead of data #5028

Merged
merged 2 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/runtime/internal/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function dataset_dev(node: HTMLElement, property: string, value?: any) {

export function set_data_dev(text, data) {
data = '' + data;
if (text.data === data) return;
if (text.wholeText === data) return;

dispatch_dev("SvelteDOMSetData", { node: text, data });
text.data = data;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/internal/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export function claim_space(nodes) {

export function set_data(text, data) {
data = '' + data;
if (text.data !== data) text.data = data;
if (text.wholeText !== data) text.data = data;
}

export function set_input_value(input, value) {
Expand Down
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');
}
};
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>