Skip to content

Conversation

@jacwright
Copy link
Contributor

{@strict text} will only update the text node if the text node's value is not equal. E.g. instead of

text.data = data;

strict will use

if (text.data !== data) text.data = data;

This is only needed (from what I can tell) in contenteditable situations where the user can update the text in the Node outside of Svelte's data source. In this situation, Svelte needs to check if the value is equal so it doesn't overwrite a text composition in action. This applies to writing letters such as é and in languages such as Thai.

See https://v3.svelte.technology/repl?version=3.0.0-beta.22&gist=93c7a0c8399348d8e9a86964aef9f8fb for a bit more about this.

`{@strict text}` will only update the text node if the text node's value is not equal.

This is only needed (from what I can tell) in contenteditable situations where the user can update the text and the text must catch up.

See https://v3.svelte.technology/repl?version=3.0.0-beta.22&gist=93c7a0c8399348d8e9a86964aef9f8fb for a bit more about this.
@jacwright jacwright requested a review from Rich-Harris March 29, 2019 22:45
@codecov-io
Copy link

codecov-io commented Mar 29, 2019

Codecov Report

Merging #2341 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2341   +/-   ##
=======================================
  Coverage   91.83%   91.83%           
=======================================
  Files           1        1           
  Lines          49       49           
=======================================
  Hits           45       45           
  Misses          4        4

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a824a6d...fad119e. Read the comment docs.

@Rich-Harris
Copy link
Member

I wonder whether the cost of checking the current text.value is low enough that this should just be the default?

@jacwright
Copy link
Contributor Author

I suppose since it isn't a unique part of a component that it won't increase the file size except for the few bytes. I would think it is better than increasing the API footprint.

jacwright added a commit that referenced this pull request Apr 3, 2019
Only update the text node if the text node's value is not equal. This fix is for contenteditable usage where text content may change outside of Svelte's control in order to preserve text composition.

Accomplishes the same thing as #2341 without the added API.
@jacwright
Copy link
Contributor Author

Closed in favor of #2357.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants