Skip to content
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

Get rid of isValidElement and Children #27

Closed
wants to merge 2 commits into from

Conversation

molefrog
Copy link
Owner

Why? because these methods are not provided by Preact and can be replaced with more simplified versions.

isValidElement is replaced with element && element.props.

// preact
element && ((element instanceof VNode) || element.$$typeof===REACT_ELEMENT_TYPE)

// react
typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE

React's Children iteration supports things like generators, edge cases like falsey children etc.

@codecov-io
Copy link

Codecov Report

Merging #27 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #27      +/-   ##
==========================================
- Coverage   98.42%   98.41%   -0.02%     
==========================================
  Files           5        5              
  Lines         127      126       -1     
  Branches       26       24       -2     
==========================================
- Hits          125      124       -1     
  Misses          2        2
Impacted Files Coverage Δ
index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 580a65a...eaf6d39. Read the comment docs.

@molefrog molefrog mentioned this pull request May 18, 2019
4 tasks
@molefrog
Copy link
Owner Author

After a discussion with @StrayFromThePath we have decided to keep isValidElement method and provide an implementation for Preact, since the hack didn't seem to be secure.

Closing this and moving to #30

@molefrog molefrog closed this May 19, 2019
@molefrog molefrog deleted the chore/switch-no-deps branch May 19, 2019 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants