google / incremental-dom

An in-place DOM diffing library
http://google.github.io/incremental-dom/
Apache License 2.0
3.54k stars 180 forks source link

When importing DOM, apply statics with different values. #374

Closed sparhami closed 6 years ago

sparhami commented 6 years ago

When importing server rendered DOM, statics may not match when Elements are reused. Ideally, a no-op patch should be applied (which would avoid this problem), but it is not always feasible. Ideally, key should also be used when statics are used, but some server-side rendered DOM might omit keys (e.g. to reduce the payload transmitted).

For example, if you have something like:

{if $condition}
  <div class="a"></div>
{else}
  <div class="b"></div>
{/if}

If the condition changes on the first patch (did not do a no-op patch), and you do not include keys in the server rendered DOM, then we want to make sure we end up with the right class value.