Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    children(function(el) {
      var a, b, c;
      a = input(props({ type: 'email' }));
      el.email = a;
      // etc
      return [a, b, c];
    })
Entirely guesswork but: El is the form element you're defining children on. You need to provide references to the elements you're creating so that you can use them later (el.email and friends) but you also need to return them to the children function in an ordered manner so that it can actually attach them into the DOM.


Aah of course; By reading the source code of the children function I figured the array of elements returned was appended to the parent element. The strange thing was that it was also adding them to `el` object but indeed it appears this is done to maintain a reference to the children so they can be modified later (which I would have seen had i read the example a bit more carefully :S )

I'm still not sure how I feel about that bit of code though but it sure is clever...


Yeah, check out my another library FRZR too: https://frzr.js.org

Point is to be able to design: 1) how you create component 2) how you update it Both 1) and 2) are just simple functions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: