fix: cursor jumping and use set instead of lsit

This commit is contained in:
Jonathan Kelley committed 2022-01-10 12:04:54 -05:00
1 parent 02d995e3f7
commit be614e6535
1 file changed
+32 -30
+32 -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) {
@@ -386,7 +386,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 +401,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);