-
-
Notifications
You must be signed in to change notification settings - Fork 111
Closed
Description
I maybe misunderstanding how hyperHTML works, but in the first case of the example below, only the last usage of icon
is rendered. Does hyperHTML move the elements into the DOM instead of cloning them?
See minimal reproduction: https://codepen.io/sidvishnoi/pen/VwaqwzM
// Case 1:
const icon = hyperHTML`<em>🚫</em>`;
for (const num of [1, "2", "3 only last SVG is rendered"]) {
const contents = [];
contents.push(hyperHTML`<span>${icon} ${num}</span>`);
// ...
document.getElementById("main1").append(hyperHTML`<h2>${contents}</h2>`);
}
// Case 2:
for (const num of [4, 5, 6]) {
const icon = hyperHTML`<em>✅</em>`;
const contents = [];
contents.push(hyperHTML`<span>${icon} ${num}</span>`);
// ...
document.getElementById("main2").append(hyperHTML`<h2>${contents}</h2>`);
}
console.log(document.getElementById("main1").innerHTML);
console.log(document.getElementById("main2").innerHTML);
Metadata
Metadata
Assignees
Labels
No labels