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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

add server-side hyperscript support #127

Merged
merged 1 commit into from Apr 17, 2018
Merged

Conversation

ungoldman
Copy link
Member

@ungoldman ungoldman commented Apr 16, 2018

Hello! 馃憢

I'd very much like to help encourage interoperability between the bel/nanohtml and hyperscript ecosystems. In the browser, there are no issues, but in a node environment, some implementation details between pelo/nanohtml/lib/server.js and create-element make things a little trickier.

When trying to render a hyperscript element inside of a nanohtml statement, I get the following error:

$ node example.js
/Users/ng/dev/modules/hyperaxe/node_modules/nanohtml/lib/server.js:61
    return Object.keys(value).reduce(function (str, key, i) {
                              ^

RangeError: Maximum call stack size exceeded
    at Array.reduce (<anonymous>)
    at handleValue (/Users/ng/dev/modules/hyperaxe/node_modules/nanohtml/lib/server.js:61:31)
    at /Users/ng/dev/modules/hyperaxe/node_modules/nanohtml/lib/server.js:71:21
    at Array.reduce (<anonymous>)
    at handleValue (/Users/ng/dev/modules/hyperaxe/node_modules/nanohtml/lib/server.js:61:31)
    at /Users/ng/dev/modules/hyperaxe/node_modules/nanohtml/lib/server.js:71:21
    at Array.reduce (<anonymous>)
    at handleValue (/Users/ng/dev/modules/hyperaxe/node_modules/nanohtml/lib/server.js:61:31)
    at /Users/ng/dev/modules/hyperaxe/node_modules/nanohtml/lib/server.js:71:21
    at Array.reduce (<anonymous>)

With the addition of a single line check for an outerHTML property, the issue is resolved.

$ node example.js

    <body>
     <h1>count is 0</h1>
     <button>Increment</button>
    </body>

Would maintainers be open to including this line in nanohtml for the sake of interoperability?

Note: sorry the commit message has an extra word, can be fixed with squash merge.

@ungoldman ungoldman changed the title add support server-side hyperscript support add server-side hyperscript support Apr 16, 2018
Copy link
Member

@goto-bus-stop goto-bus-stop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it!

@ungoldman ungoldman merged commit 3c0bac4 into choojs:master Apr 17, 2018
@ungoldman ungoldman deleted the hyperscript branch April 17, 2018 15:39
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.

None yet

2 participants