Live data from Hacker News

RE:DOM – Tiny DOM library

redom.js.org

31–40 of 84 posts

Re: RE:DOM – Tiny DOM library

#31
post #13

Honest question, how is: el.email = input(props({ type: 'email' })) better or easier than: I think the example needs to be more compelling.

Using crel as a comparison:

var input = crel('input', {type:'email'});

vs:

var wrapper = document.createElement('div'); wrapper.innerHTML = ''; var input = wrapper.children[0];

Re: RE:DOM – Tiny DOM library

#35

I'm torn. On the one hand this seems far too clever for it's own good and in the same vein as coffeescript where it's really easy for you to write efficient & compact code which somehow turns into complete garbage when you try to read it two weeks later. On the other hand it looks super neat, has 0 dependencies and looks like React but without requiring any kind of build system. I think I might need to try it in a si…

If you like React but want to avoid a build system, you can always do

  var form = React.createFactory('form');
  form({...}, ...);
or

  var e = React.createElement;
  e('form', {...}, ...);

Re: RE:DOM – Tiny DOM library

#36
post #13

Honest question, how is: el.email = input(props({ type: 'email' })) better or easier than: I think the example needs to be more compelling.

In general case, (for all other props), please don't forget to escape a quote in you prop's values.

Re: RE:DOM – Tiny DOM library

#37
post #21

Earlier quoted context omitted.

I assume you mean to compare it to: el.email = (function(){ var input = document.createElement('input'); input.type = "email"; return input; })(); ...or something similar. Your could also use createContextualFragement or a little function that uses innerHTML, both of which parse a string into HTML (which is problematic). Or you could use a templating library, of which there are many and this is one.

$(' ')

I recently had the pleasure of tracking down the source code for how this works. There are a few methods, but the main one is at least a hundred lines long.
Post reply on HN