bikeshaving / crank

The Just JavaScript Framework
https://crank.js.org
MIT License
2.7k stars 75 forks source link

The `innerHTML` prop triggers unnecessary DOM mutations #213

Closed brainkim closed 3 years ago

brainkim commented 3 years ago

When you assign to innerHTML , the browser will normalize the contents, so that, for instance, void elements like <img /> become <img>. This means that we’re still setting innerHTML even if it might not be necessary, because Crank checks each prop value against the actual DOM before deciding to set the property (https://github.com/bikeshaving/crank/blob/3b3f8ee5334532b30cc6c86c4120c6791290d817/src/dom.ts?ts=2#L118)

Perhaps this is a more general problem? Are there other DOM properties which can change between setting and getting, such that checking the value against the DOM isn’t actually useful? Something to think about.

brainkim commented 3 years ago

Fixed in 0.4.0