Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also support the hyperscript-helpers syntax with a Proxy #73

Closed
wants to merge 1 commit into from

Conversation

kynikos
Copy link

@kynikos kynikos commented Sep 20, 2017

This PR adds native support for the hyperscript-helpers syntax with only a few more lines of code, using a Proxy object. The idea was also inspired by https://stackoverflow.com/a/40075864/645498

Usage example:

var { B, P, Span } = h = require("hyperscript");
var div = h('div', "foo");
var span = Span("bar");
var span2 = h('span', B("yay"));
var p = P("bla", h('span', "test"));

Actually I also submitted a similar PR on hyperscript-helpers, but I thought that since it's so little code, I could try here too :)

Many tests fail, but it also happens on the current master branch, see #68, so I've verified that this patch works with other custom scripts.

I'm not sure if I've given enough credit to the hyperscript-helpers contributors with the comment in the code: if you like this patch we may find better ways solve that issue. Also, if merged, the docs should be changed, and in that case I'll help too of course. Cheers!

Example:
```
var h = require("hyperscript");
var { Span } = h;
var div = h('div', "foo");
var span = Span("bar");
```
@dominictarr
Copy link
Collaborator

thanks, but I'm worried that this feature means hyperscript won't work in older browsers. Having the simplest way to create html elements is undermined if it doesn't work in simple browers, that said - if this was published as a module I'd be very happy to link to it from the hyperscript readme.

Also, we are at the stage where we are talking about standardizing all the hyperscript like apis, and adding sugar at this point would make that harder.

@kynikos
Copy link
Author

kynikos commented Sep 21, 2017

Thank you for reviewing my patch, I perfectly understand your points, so I withdraw this PR and will see what they tell me at hyperscript-helpers (probably the same). If I get around to making a module out of this, I'll ask a link from the readme :) Cheers

@kynikos kynikos closed this Sep 21, 2017
@kynikos kynikos changed the title Also support the hyperscript-helpers with a Proxy Also support the hyperscript-helpers syntax with a Proxy Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants