Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

syntax of h #199

Closed
caub opened this issue Jan 19, 2016 · 2 comments
Closed

syntax of h #199

caub opened this issue Jan 19, 2016 · 2 comments

Comments

@caub
Copy link

caub commented Jan 19, 2016

Hi, what are your sights on the syntax:

h('html', [
  h('head', [
    h('title', 'Server side rendering')
    ]),
  h('body', [
    content,
    h('script', JSONGlobals({
      state: state
    })),
    h('script', {
      src: 'bundle.js'
    })
    ])
  ]);

// vs

h('html').add(
  h('head').add(
    h('title').text('Server side rendering')
  ),
  h('body').add(
    content,
    h('script').add(JSONGlobals({
      state: state
    })),
    h('script').attr({
      src: 'bundle.js'
    })
  )
);

personally I prefer the second, even if slightly more verbose it's a bit more clear, .text is a shortcut for .attr({text..: ..})

var tree = h('div.foo#some-id', [
    h('span', 'some text'),
    h('input', { type: 'text', value: 'foo' })
]);

would be

var tree = h('div.foo#some-id').add(
    h('span').text('some text'),
    h('input').attr({ type: 'text', value: 'foo' })
);

@Raynos (sorry to ping you:), would appreciate your input)

@gcallaghan
Copy link
Contributor

Isn't this really more of a hyperscript question?

@caub
Copy link
Author

caub commented Jan 19, 2016

sorry I realized it too, will move it there, thanks

Matt-Esch/virtual-dom#364

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants