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 } 166 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", "") 171 } 172 173 - if (element.checked !== element.defaultChecked) { 174 - element.setAttribute("morphlex-dirty", "") 175 } 176 } 177 178 for (const element of node.querySelectorAll("option")) { 179 if (element.selected !== element.defaultSelected) { 180 element.setAttribute("morphlex-dirty", "") 181 }
··· 165 } 166 167 function flagDirtyInputs(node: ParentNode): void { 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", "") 173 } 174 175 + if (input.checked !== input.defaultChecked) { 176 + input.setAttribute("morphlex-dirty", "") 177 } 178 } 179 180 for (const element of node.querySelectorAll("option")) { 181 + if (element.value === "") continue 182 + 183 if (element.selected !== element.defaultSelected) { 184 element.setAttribute("morphlex-dirty", "") 185 }