Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
inconsistent or duplicate elements rendered when using preact standalone version #159
Comments
|
Hi @catdad - this happens because you are using two copies of Preact - Some context - the reason we don't export However: it looks like the copy of Preact we bundled with htm 3.0.3 has a bug with fragments at the root, or our bundling is breaking something. That's a bug. Here's your demo without the Fragment usage: // should work, but seems to have an issue with bundled preact and fragments:
//import { html, render } from 'https://cdn.jsdelivr.net/npm/htm@3.0.3/preact/standalone.module.js';
import { h, render } from 'https://cdn.jsdelivr.net/npm/preact@10.3.4/dist/preact.module.js';
import htm from 'https://cdn.jsdelivr.net/npm/htm@3.0.3/dist/htm.module.js';
const html = htm.bind(h);
const elem = document.querySelector("#app");
const Item = (item) => {
return html`
<div key=${item.id} data-id=${item.id}>
${item.text}
</div>`;
};
const items = [{id: 1, text: 'one'}, { id: 2, text:'two' }];
const performRender = () => {
const children = items.map(item => html`<${Item} ...${item} />`);
render(html`${children.reverse()}`, elem);
};
setTimeout(() => {
items.push({ id: 3, text: 'three'});
performRender();
}, 1000);
setTimeout(() => {
items.push({ id: 4, text: 'four'});
performRender();
}, 2000);
window.onload = performRender; |
Fix render() in standalone build (fixes #159)
|
This has been fixed! It's available on unpkg and npm as htm 3.0.4. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

I created a small repro demo that I set up in two ways:
preact@10.3.4withhtm@3.0.3htm@3.0.3with the preact standalone version of the moduleCode:
Fiddle for reference: https://jsfiddle.net/0ukweoz1/2/
Results:
note that also, the render after 1 second does not actually update the DOM, so
threeis never just added by itself