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

Conversation

remarkablemark
Copy link
Owner

@remarkablemark remarkablemark commented Oct 29, 2023

What is the motivation for this pull request?

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

What is the current behavior?

props.children defaults to null. E.g., parse('<br>'):

{
  '$$typeof': Symbol(react.element),
  type: 'br',
  key: null,
  ref: null,
  props: { children: null },
  _owner: null,
  _store: {}
}

What is the new behavior?

props.children defaults to undefined

This ensures the parsed element is consistent with the React element <br >:

{
  '$$typeof': Symbol(react.element),
  type: 'br',
  key: null,
  ref: null,
  props: {},
  _owner: null,
  _store: {}
}

Checklist:

@remarkablemark remarkablemark added the bug Something isn't working label Oct 29, 2023
@remarkablemark remarkablemark self-assigned this Oct 29, 2023
@codecov
Copy link

codecov bot commented Oct 29, 2023

Codecov Report

Merging #1127 (a6978c3) into master (57571aa) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #1127   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          153       153           
  Branches        50        50           
=========================================
  Hits           153       153           
Files Coverage Δ
src/dom-to-react.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
dist/html-react-parser.min.js 10.2 KB (0%) 205 ms (0%) 26 ms (+104.93% 🔺) 230 ms

@remarkablemark remarkablemark merged commit 6f9ae44 into master Oct 29, 2023
@remarkablemark remarkablemark deleted the fix/dom-to-react branch October 29, 2023 19:41
@remarkablemark
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant