WebReflection / hyperHTML

A Fast & Light Virtual DOM Alternative
ISC License
3.07k stars 112 forks source link

wire`...`.valueOf(reAppend=false) #285

Closed WebReflection closed 5 years ago

WebReflection commented 5 years ago

The wire is different from bind because it lives outside the live DOM.

There are cases where a wire could produce a fragment instead of a single node. In the latter scenario, the node won't leave the DOM with successful updates. However, when it's a fragment, all childrewn are re-appended each time to grant the slot associated to the fragmnent will always have expected children.

However, there are cases where a wire is needed for a single element or component, where nodes should be appended once and never again.

In such case, it is always possible to use valueOf(false) or just .valueOf() to be sure that nodes won't ever leave again the DOM.

Using valueOf() is safe for any returned DOM node too since it's returning just itself.

Pleaase see the test/haunted.html and debug the nodes to see why this is needed, switching between valueOf() and valueOf(true).

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 675


Totals Coverage Status
Change from base Build 674: 0.0%
Covered Lines:
Relevant Lines: 0

💛 - Coveralls