Skip to content

Commit

Permalink
vecnatechnologies#396: Bail if attr cannot be removed during render
Browse files Browse the repository at this point in the history
  • Loading branch information
jyoung committed Jun 2, 2019
1 parent 1f65f59 commit 0d17ca9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/templateRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,19 @@
// This is necessary, because some types of attributes cannot be removed
// without causing a browser error.
currentAttributes = currentNode.attributes;
var prevLength = currentAttributes.length;
while (idx < currentAttributes.length) {
currentAttr = currentAttributes[idx].name;
if (newNode.getAttribute(currentAttr)) {
idx++;
} else {
currentNode.removeAttribute(currentAttr);
if (prevLength === currentAttributes.length) {
// bail since we can't remove the attribute.
$currentNode.replaceWith(newNode);
return;
}
prevLength = currentAttributes.length;
}
}

Expand Down

0 comments on commit 0d17ca9

Please sign in to comment.