2 ms·
> And virtual DOM reconciliation implementations in browsers can use only public APIs like appendChild(). Why can't they also use innerHTML? Meaning, they cou
by quelltext 4y ago
> And virtual DOM reconciliation implementations in browsers can use only public APIs like appendChild().
Why can't they also use innerHTML?
Meaning, they could define a cost function where they deduce that it's cheaper to use innerHTML on a potentially larger than necessary scope if the alternative is >some_threshold for modification API calls.
- scotty79 4y agoProbably because we are doing diff per node so we'd have to aggregate diffs somehow, rip out children that don't change to reattach them into the change part recreated using innerHTML.
- mtsr 4y agoThey could, but they would have to either render the whole scope again or somehow apply the change to a copy of the scopes HTML and then set that. Neither seems ideal, but that may be a reasonable, if complex, optimization.