Do not set attribute/property value if it hasn't changed #2625
tjenkinson
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
Change detection is an important optimization for us because reading from the DOM is slower than reading from JS. To disable the change detection and read the previous value from the DOM you can use the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was setting an
<input />
.value
back to the new value of the input after the user updated it, and it appears this causeslit-html
to actually set the.value
(given it changed from the cached one). This works fine in chrome, but on iOS setting the value back to itself appears to cause the cursor to jump to the end of the line.I wonder if it would be possible to update the place that actually sets a property/value when a change is detected to first read the existing value, and skip setting it if it hasn't changed?
For context here is the current workaround I did to solve the problem, but it would be nice if this change wasn't needed: tjenkinson/redos-detector-demo#34
I think it might just be a change here
lit/packages/lit-html/src/lit-html.ts
Line 1912 in b8ceafb
to go from that to something like
Thoughts?
Happy to open a PR/proper issue.
Beta Was this translation helpful? Give feedback.
All reactions