Skip to content

Support fragments via h(null, null, ...args) - #16

Merged
developit merged 8 commits into
developit:masterfrom
ithinkihaveacat:support-fragments
May 23, 2019
Merged

developit merged 8 commits into
developit:masterfrom
ithinkihaveacat:support-fragments

Conversation

@ithinkihaveacat

Copy link
Copy Markdown
Contributor

How do you feel about supporting "fragments" via the form h(null, null, "foo", "bar", "baz") => foobarbaz? (Without this PR, the return value is <null>foobarbaz</null>.)

This would make it possible to use JSX's fragment short form (<>...</>) via TypeScript. It will only become easy to do once microsoft/TypeScript#20469 is fixed, but with this PR, it at least becomes possible with workaround wrapper code such as:

import h = require("vhtml");

export const React = {
  createElement: h,
  Fragment: ({ children }: { children: string[] }) => h(null, null, ...children),
};
@developit

Copy link
Copy Markdown
Owner

@ithinkihaveacat sorry for the long wait - I think Fragments should be supported.

@developit

developit commented May 23, 2019 •

Copy link
Copy Markdown
Owner

I PR'd a possible size optimization for this PR here: github.com/ithinkihaveacat/pull/1
Nevermind, it was smaller so I've just merged it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants