chinedufn / percy

Build frontend browser apps with Rust + WebAssembly. Supports server side rendering.
https://chinedufn.github.io/percy/
Apache License 2.0
2.26k stars 84 forks source link

Support keyed lists #188

Closed chinedufn closed 1 year ago

chinedufn commented 1 year ago

This commit adds support for a key="some-key" attribute.

When elements in a list are keyed the diffing and patching functions will use their keys to know whether an element was removed or simply moved.

This leads to fewer interactions with the real-DOM when modifying lists, as well as preserving child elements when keyed elements are moved around in the list.

This preservation is useful when you have an element that has children that aren't managed by percy-dom. Before this commit those children would get deleted if the element within the list was moved.