WebReflection / hyperHTML

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

Nested HyperHtml wire is not working #354

Closed alameenkh7 closed 5 years ago

alameenkh7 commented 5 years ago

I tried to nest wire inside a wire. But the wire is only happening to the last element.

here is the code : https://codepen.io/alameenkh/pen/ZZbaeM?editors=0010

do you support nested wire. Is there any alternate way to tackle this issue

Thanks

WebReflection commented 5 years ago
var del = () => hyperHTML.wire()`<button>delete</button>`;

the would do, however, you'll create new nodes every single time.

You need to understand how wire works before nesting it.

A wire can have an object and and optional :id to be unique.

If you wire an element once, you just create a node once. If you use that node N times, it'll just be where last time you placed it.

This is also how the DOM work so probably you also need to understand how regular nodes are moved before nesting wires.

However, to answer your question: yes, nested wires are supported since these are just an indirection for nested DOM nodes which are naturally supported.

alameenkh7 commented 5 years ago

Thanks for the very prompt reply.

On Wed, Apr 3, 2019 at 2:52 PM Andrea Giammarchi notifications@github.com wrote:

var del = () => hyperHTML.wire()<button>delete</button>;

the would do, however, you'll create new nodes every single time.

You need to understand how wire works before nesting it.

A wire can have an object and and optional :id to be unique.

If you wire n element once, you just create a node once. If you use that node N times, it'll just be where last time you placed it.

This is also how the DOM work so probably you also need to understand how regular nodes are moved before nesting wires.

However, to answer your question: yes, nested wires are supported since these are just an indirection for nested DOM nodes which are naturally supported.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/WebReflection/hyperHTML/issues/354#issuecomment-479410660, or mute the thread https://github.com/notifications/unsubscribe-auth/AP0d5D0NZpLS8ELd3Ej08OOCnp4O535_ks5vdHLpgaJpZM4caAwL .

--

Al Ameen K H Software Engineer https://www.linkedin.com/in/al-ameen https://www.linkedin.com/in/al-ameen-90a023114?trk=nav_responsive_tab_profile_pic contact at: 8113871897 alameenkh7@gmail.com