maciejhirsz / kobold

Easy declarative web interfaces.
https://docs.rs/kobold/
Mozilla Public License 2.0
385 stars 7 forks source link

Generic Anchor #43

Closed maciejhirsz closed 1 year ago

maciejhirsz commented 1 year ago

This replaces the dom::Element type with a generic trait Anchor implemented for types:

  1. Node: regular DOM node
  2. dom::Fragment: transparent wrapper around Node referencing a document fragment.
  3. dom::DynAnchor: transparent wrapper around JsValue that may or may not be referencing a document fragment.

In addition the Mountable trait has provided unmount and replace_with methods that should always be used directly instead of calling mountable.anchor().unmount() or mountable.anchor().replace_with(new).

This removes a lot of branching when unmounting and replacing elements in the DOM, which once again produces smaller Wasm binaries and should improve runtime performance.