diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index f67fd13b2d..08e82c0e56 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -155,14 +155,16 @@ export function claim_element(nodes, name, attributes, svg) { const node = nodes[i]; if (node.nodeName === name) { let j = 0; + const remove = []; while (j < node.attributes.length) { - const attribute = node.attributes[j]; - if (attributes[attribute.name]) { - j++; - } else { - node.removeAttribute(attribute.name); + const attribute = node.attributes[j++]; + if (!attributes[attribute.name]) { + remove.push(attribute.name); } } + for (let k = 0; k < remove.length; k++) { + node.removeAttribute(remove[k]); + } return nodes.splice(i, 1)[0]; } }