Precise DOM morphing
morphing typescript dom

Only perform dirty tracking on inputs with names and options with values

+9 -5
+9 -5
src/morphlex.ts
··· 165 165 } 166 166 167 167 function flagDirtyInputs(node: ParentNode): void { 168 - for (const element of node.querySelectorAll("input")) { 169 - if (element.value !== element.defaultValue) { 170 - element.setAttribute("morphlex-dirty", "") 168 + for (const input of node.querySelectorAll("input")) { 169 + if (input.name === "") continue 170 + 171 + if (input.value !== input.defaultValue) { 172 + input.setAttribute("morphlex-dirty", "") 171 173 } 172 174 173 - if (element.checked !== element.defaultChecked) { 174 - element.setAttribute("morphlex-dirty", "") 175 + if (input.checked !== input.defaultChecked) { 176 + input.setAttribute("morphlex-dirty", "") 175 177 } 176 178 } 177 179 178 180 for (const element of node.querySelectorAll("option")) { 181 + if (element.value === "") continue 182 + 179 183 if (element.selected !== element.defaultSelected) { 180 184 element.setAttribute("morphlex-dirty", "") 181 185 }