-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Components: Improve empty elements filters in Slot implementation #9371
Conversation
ae4a484
to
53da43e
Compare
isNumber, | ||
} from 'lodash'; | ||
|
||
export const isEmptyElement = ( element ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use it only here, if there is going to be another use case, we could think to move it @wordpress/element
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a nice improvement. The only edge-case I can think of is isEmptyElement( new String( '' ) )
, which I think would return false. It'd be pretty easy to fix that using the same approach used with arrays.
Would also be great to add jsdocs for isEmptyElement
53da43e
to
39e2b3f
Compare
Correct, I updated the way we validate strings to accommodate that. I skipped a similar check for
Added. |
Great - I'm happy with those changes.
🤞 hopefully! |
This pierces the abstraction of |
I suppose it's okay to allow this to be deferred as it relates to a 3.8 RC, only because it's not part of a public API. |
I left my own comment about it #9371 (comment) where I assumed we don't want to expose it in |
In that case I'd rather just flag it as experimental. My main issue is that, as far as anything in |
Opened #9681 with the proposed change. Let's continue there. |
Description
Raised by @aduth in #5952 (comment):
This PR adds
isEmptyElement
helper method and adds proper inline documentation explaining why it is used withfills
.How has this been tested?
npm test
Types of changes
Refactoring.
Checklist: