Closed jonathantneal closed 5 years ago
Hi, Thanks for your issue, I have some questions.
by the way the work of @WebReflection is incredible, I have analyzed its code as part of my learning
I have analyzed it and I have not used domdiff for this.
<host />
, this tag is designed to facilitate work with WC.
class Tag extends Element {
/**❌**/
constructor() {
super();
this.attachShadow({ mode: "open" });
this.style.background = "black";
this.addEventListener("click", () => {
console.log("event!");
});
}
/**✔️**/
render() {
return (
<host
shadowDom
onClick={() => console.log("event")}
style={{ background: "black" }}
/>
);
}
}
I tried your diffing algorithm and experienced the recreation/reloading of images and iframe elements whenever others elements were prepended before them. This can happen frequently when creating filter-able lists that contain media.
To resolve this, check out the O(ND) Difference Algorithm and Its Variations as well as these pre-optimizations. Alternatively, consider leveraging a third-party library like
domdiff
.I can write a patcher for you over domdiff, but it would come in around 1.52 kB min/gzip — which isn’t too bad when domdiff is 1.5 kB min/gzip by itself.