Merge pull request #113 from DioxusLabs/jk/desktop-cursor-jump

fix: cursor jumping in desktop inputs
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2022-01-10 12:20:13 -05:00
commit 20a29409b2
1 file changed
+33 -30
+33 -30
View File
@@ -1,31 +1,31 @@
const bool_attrs = [ const bool_attrs = {
"allowfullscreen", allowfullscreen: true,
"allowpaymentrequest", allowpaymentrequest: true,
"async", async: true,
"autofocus", autofocus: true,
"autoplay", autoplay: true,
"checked", checked: true,
"controls", controls: true,
"default", default: true,
"defer", defer: true,
"disabled", disabled: true,
"formnovalidate", formnovalidate: true,
"hidden", hidden: true,
"ismap", ismap: true,
"itemscope", itemscope: true,
"loop", loop: true,
"multiple", multiple: true,
"muted", muted: true,
"nomodule", nomodule: true,
"novalidate", novalidate: true,
"open", open: true,
"playsinline", playsinline: true,
"readonly", readonly: true,
"required", required: true,
"reversed", reversed: true,
"selected", selected: true,
"truespeed", truespeed: true,
] };
function serialize_event(event) { function serialize_event(event) {
switch (event.type) { switch (event.type) {
@@ -321,6 +321,7 @@ class Interpreter {
CreatePlaceholder(edit) { CreatePlaceholder(edit) {
let el = document.createElement("pre"); let el = document.createElement("pre");
el.hidden = true;
this.stack.push(el); this.stack.push(el);
this.nodes[edit.root] = el; this.nodes[edit.root] = el;
} }
@@ -386,7 +387,9 @@ class Interpreter {
} else { } else {
switch (name) { switch (name) {
case "value": case "value":
node.value = value; if (value != node.value) {
node.value = value;
}
break; break;
case "checked": case "checked":
node.checked = value === "true"; node.checked = value === "true";
@@ -399,7 +402,7 @@ class Interpreter {
break; break;
default: default:
// https://github.com/facebook/react/blob/8b88ac2592c5f555f315f9440cbb665dd1e7457a/packages/react-dom/src/shared/DOMProperty.js#L352-L364 // https://github.com/facebook/react/blob/8b88ac2592c5f555f315f9440cbb665dd1e7457a/packages/react-dom/src/shared/DOMProperty.js#L352-L364
if (value == "false" && bool_attrs.indexOf(name)) { if (value == "false" && bool_attrs.hasOwnProperty(name)) {
node.removeAttribute(name); node.removeAttribute(name);
} else { } else {
node.setAttribute(name, value); node.setAttribute(name, value);