From 4085b2d30322a09f63a80d7ae0ac27e3658b493a Mon Sep 17 00:00:00 2001 From: Aria Stewart Date: Tue, 26 May 2020 18:37:48 -0400 Subject: [PATCH] Separate the id and removal of attributes Because EdgeHTML does not actually remove the 'value' attribute from an HTMLInputElement, the prior iteration would generate an infinite loop. By making this two passes, we are a bit less memory efficient but avoid the nasty edge cases when DOM elements don't fully respect the API. --- src/runtime/internal/dom.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 02fd3dc23e..9d59ba0434 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]; } }