From a6978c31acde279437e502106cd39ef0d0a34b87 Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 29 Oct 2023 15:26:43 -0400 Subject: [PATCH] fix(dom-to-react): default props.children to undefined instead of null --- __tests__/dom-to-react.test.tsx | 2 +- src/dom-to-react.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/__tests__/dom-to-react.test.tsx b/__tests__/dom-to-react.test.tsx index 3add2a40..e99509df 100644 --- a/__tests__/dom-to-react.test.tsx +++ b/__tests__/dom-to-react.test.tsx @@ -84,7 +84,7 @@ describe('domToReact', () => { it('does not have `children` for void elements', () => { const reactElement = domToReact(htmlToDOM(html.img)) as JSX.Element; - expect(reactElement.props.children).toBe(null); + expect(reactElement.props.children).toBe(undefined); }); it('does not throw an error for void elements', () => { diff --git a/src/dom-to-react.ts b/src/dom-to-react.ts index 01eb41f6..70780e65 100644 --- a/src/dom-to-react.ts +++ b/src/dom-to-react.ts @@ -96,7 +96,7 @@ export default function domToReact( props = attributesToProps(element.attribs, element.name); } - let children = null; + let children; switch (node.type) { case 'script':