@@ -49,7 +49,20 @@ const OP_TABLE = [
4949 const pointer2 = mem32[i++];
5050 const length2 = mem32[i++];
5151 const value = string(mem8, pointer2, length2);
52− top(changeList.stack).setAttribute(name, value);
52+ const node = top(changeList.stack);
53+ node.setAttribute(name, value);
54+
55+ // Some attributes are "volatile" and don't work through `setAttribute`.
56+ if (name === "value") {
57+ node.value = value;
58+ }
59+ if (name === "checked") {
60+ node.checked = true;
61+ }
62+ if (name === "selected") {
63+ node.selected = true;
64+ }
65+
5366 return i;
5467 },
5568
@@ -58,7 +71,20 @@ const OP_TABLE = [
5871 const pointer = mem32[i++];
5972 const length = mem32[i++];
6073 const name = string(mem8, pointer, length);
61− top(changeList.stack).removeAttribute(name);
74+ const node = top(changeList.stack);
75+ node.removeAttribute(name);
76+
77+ // Some attributes are "volatile" and don't work through `removeAttribute`.
78+ if (name === "value") {
79+ node.value = null;
80+ }
81+ if (name === "checked") {
82+ node.checked = false;
83+ }
84+ if (name === "selected") {
85+ node.selected = false;
86+ }
87+
6288 return i;
6389 },
6490