Skip to content

fix(dom-to-react): default props.children to undefined instead of null #1127

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/dom-to-react.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/dom-to-react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default function domToReact(
props = attributesToProps(element.attribs, element.name);
}

let children = null;
let children;

switch (node.type) {
case 'script':
Expand Down