-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: use wholeText
for only contenteditable
for set_data
#8394
Merged
Merged
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c930455
fix: same-text-no-update
suxin2017 fbf0ed9
fix: same-text-no-update
suxin2017 6bbacfb
chore: a problem
suxin2017 c257ff1
fix: empty fix
suxin2017 3caa3a7
feat: add reactive-values-text-node test case
suxin2017 8a0b897
Merge branch 'master' into fix-same-text-no-update
dummdidumm aa147fc
Merge remote-tracking branch 'origin/master' into fix-same-text-no-up…
baseballyama a128e3c
fix 5931
baseballyama 535623d
refactor and split runtine function
baseballyama 370a894
truthy
dummdidumm 1a9f566
fix double elementwrapper output in rollup; fix code
dummdidumm e6bdc5a
refactor into smaller compiler output
dummdidumm e257fd1
can't wait for prettier to land in this repo
dummdidumm 866e52a
- move tests to puppeteer because jsdom does not support contenteditable
dummdidumm 55209c4
optimize for static contenteditable value
dummdidumm 05f0927
ffs
dummdidumm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
5 changes: 1 addition & 4 deletions
5
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 |
---|---|---|
@@ -1,15 +1,12 @@ | ||
export default { | ||
html: ` | ||
<div contenteditable=""></div> | ||
`, | ||
html: '<div contenteditable=""></div>', | ||
|
||
async test({ assert, 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'); | ||
} | ||
}; |
12 changes: 12 additions & 0 deletions
12
test/runtime/samples/component-event-handler-contenteditable2/_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,12 @@ | ||
export default { | ||
html: '<div contenteditable="true"></div>', | ||
|
||
async test({ assert, 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-contenteditable2/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="true" on:input={updater}>{text}</div> |
13 changes: 13 additions & 0 deletions
13
test/runtime/samples/component-event-handler-contenteditable3/_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,13 @@ | ||
export default { | ||
html: '<div contenteditable="true"></div>', | ||
ssrHtml: '<div contenteditable=""></div>', | ||
|
||
async test({ assert, 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'); | ||
} | ||
}; |
9 changes: 9 additions & 0 deletions
9
test/runtime/samples/component-event-handler-contenteditable3/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,9 @@ | ||
<script> | ||
let text = ''; | ||
const updater = (event) => {text = event.target.textContent} | ||
$: spread = { | ||
contenteditable: text !== undefined, | ||
} | ||
</script> | ||
|
||
<div {...spread} on:input={updater}>{text}</div> |
12 changes: 12 additions & 0 deletions
12
test/runtime/samples/component-event-handler-contenteditable4/_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,12 @@ | ||
export default { | ||
html: '<div contenteditable="false"></div>', | ||
|
||
async test({ assert, target, component, window }) { | ||
const div = target.querySelector('div'); | ||
const text = window.document.createTextNode('a'); | ||
div.insertBefore(text, null); | ||
assert.equal(div.textContent, 'a'); | ||
component.text = 'bcde'; | ||
assert.equal(div.textContent, 'bcdea'); | ||
} | ||
}; |
6 changes: 6 additions & 0 deletions
6
test/runtime/samples/component-event-handler-contenteditable4/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> | ||
export let text = ''; | ||
const updater = (event) => {text = event.target.textContent} | ||
</script> | ||
|
||
<div contenteditable="false" on:input={updater}>{text}</div> |
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,9 @@ | ||
export default { | ||
html:'<div>same text</div>', | ||
async test({ assert, target }) { | ||
await new Promise(f => setTimeout(f, 10)); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<div>same text text</div> | ||
`); | ||
} | ||
}; |
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,8 @@ | ||
<script> | ||
let text = 'same'; | ||
setTimeout(() => { | ||
text = 'same text'; | ||
}, 5); | ||
</script> | ||
|
||
<div>{text} text</div> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to switch to
unshift
here and above? I switched it back topush
and the tests all passed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, test case
component-event-handler-contenteditable3
,get_spread_update
is added atElementWrapper
class, andset_data_maybe_contenteditable
is added atMustacheTag
class.And
MustacheTag
is executed earlier thanElementWrapper
.If
get_spread_update
runs afterset_data_maybe_contenteditable
,set_data_maybe_contenteditable
runs usingdiv_data
that is before updating.To avoid this situation, I use
unshift
.I think there are other ways to solve this issue, but I think this is reasonable and anyway, we will dynamically change the compiler in Svelte4, so we don't need to be particular about this.