Skip to content

Commit

Permalink
fix removing attributes during hydration (sveltejs#1733)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry authored and taylorzane committed Dec 17, 2020
1 parent 7325c10 commit 3b4a477
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/runtime/internal/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,16 @@ export function claim_element(nodes, name, attributes, svg) {
for (let i = 0; i < nodes.length; i += 1) {
const node = nodes[i];
if (node.nodeName === name) {
for (let j = 0; j < node.attributes.length; j += 1) {
let j = 0;
while (j < node.attributes.length) {
const attribute = node.attributes[j];
if (!attributes[attribute.name]) node.removeAttribute(attribute.name);
if (attributes[attribute.name]) {
j++;
} else {
node.removeAttribute(attribute.name);
}
}
return nodes.splice(i, 1)[0]; // TODO strip unwanted attributes
return nodes.splice(i, 1)[0];
}
}

Expand Down

0 comments on commit 3b4a477

Please sign in to comment.