Skip to content

Commit

Permalink
Allow props to be null or undefined, for parcel.js
Browse files Browse the repository at this point in the history
Using parcel.js with the following jsx pragma and code:

```jsx
/** @jsx h */
import h from 'solid-js/h'
import { render } from 'solid-js/dom'

render(
  () => <h1>HELLO</h1>,
  document.getElementById('root')
);
```
...causes it to call `h` like this:

```js
h("h1", null, "HELLO")
```

...which fails, because `props` is `null`, and is seen as being `typeof "object"`.

This commit allows `props` to be ignored if `null`, instead of being treated like an `object`.
  • Loading branch information
hugojosefson authored Jun 18, 2020
1 parent e284bc7 commit 62da817
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/hyper-dom-expressions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function createHyperScript(r: Runtime): HyperScript {
let props: Props = {},
dynamic = [],
next = args[0];
if (typeof next === "object" && !Array.isArray(next) && !(next instanceof Element))
if (typeof next === "object" && next != null && !Array.isArray(next) && !(next instanceof Element))
props = args.shift();
for (const k in props) {
if (typeof props[k] === "function") dynamic.push(k);
Expand Down

0 comments on commit 62da817

Please sign in to comment.