Skip to content

Commit

Permalink
feat: support typescript jsxFragmentFactory
Browse files Browse the repository at this point in the history
developit#31

```json
    "jsxFragmentFactory": "Fragment",
```

or

```json
    "jsxFactory": "vhtml",
    "jsxFragmentFactory": "vhtml.Fragment",
```

---

```ts
import h, { Fragment } from 'vhtml';
```
  • Loading branch information
bluelovers committed Nov 17, 2021
1 parent 96fe21e commit 76f7569
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/vhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ let DOMAttributeNames = {

let sanitized = {};

export const Fragment = ({ children }: { children: string[] }) => h(null as any, null, ...children);

/** Hyperscript reviver that constructs a sanitized HTML string. */
export default function h(name, attrs) {
function h(name, attrs) {
let stack=[], s = '';
attrs = attrs || {};
for (let i=arguments.length; i-- > 2; ) {
Expand Down Expand Up @@ -58,3 +60,7 @@ export default function h(name, attrs) {
sanitized[s] = true;
return s;
}

h.Fragment = Fragment;

export default h

0 comments on commit 76f7569

Please sign in to comment.