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.
pull/4911/head
Aria Stewart 5 years ago
parent 81b6c0b986
commit 4085b2d303

@ -155,13 +155,15 @@ export function claim_element(nodes, name, attributes, svg) {
const node = nodes[i]; const node = nodes[i];
if (node.nodeName === name) { if (node.nodeName === name) {
let j = 0; let j = 0;
const remove = [];
while (j < node.attributes.length) { while (j < node.attributes.length) {
const attribute = node.attributes[j]; const attribute = node.attributes[j++];
if (attributes[attribute.name]) { if (!attributes[attribute.name]) {
j++; remove.push(attribute.name);
} else { }
node.removeAttribute(attribute.name);
} }
for (let k = 0; k < remove.length; k++) {
node.removeAttribute(remove[k]);
} }
return nodes.splice(i, 1)[0]; return nodes.splice(i, 1)[0];
} }

Loading…
Cancel
Save