patch function
Implementation
void patch(Node dom, PulsarNode prev, PulsarNode next) {
// Tipo distinto → reemplazo
if (prev.runtimeType != next.runtimeType) {
_replace(dom, createDom(next));
return;
}
// Text
if (prev is TextNode && next is TextNode) {
if (prev.value != next.value) {
(dom as Text).data = next.value;
}
return;
}
// Element
if (prev is ElementNode && next is ElementNode) {
if (prev.tag != next.tag) {
_replace(dom, createDom(next));
return;
}
final el = dom as Element;
_patchAttributes(el, prev, next);
_patchChildren(el, prev.children, next.children);
}
}