-
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
Element: Introduce isPlainObject()
utility
#42471
Conversation
Size Change: +55 B (0%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
I don't think that |
Thanks for the feedback @gziolo! Really helpful to set the path ahead. I'm happy to create separate packages outside of the Gutenberg repo when the need comes. Going to start with As for addressing the problem of bundling multiple copies of the same package, I think we can work on it separately as part of #17025. Going to close this one and come up with an external package for this one. |
Started work on the new package in Automattic/wp-calypso#65668 - going to circle back to this one once we publish it. |
What?
This PR introduces a new local
isPlainObject()
utility to replace Lodash's version. Part of the effort to completely remove Lodash from Gutenberg.I'd like to seek some feedback on two points here:
@wordpress/element
package, given that it's necessary for rendering style attribute values? Any better place to place it?This is part of #16938.
Why?
Lodash is known to unnecessarily inflate the bundle size of packages, and in most cases, it can be replaced with native language functionality. See these for more information and rationale:
@wordpress/api-fetch
package haslodash
as a dependency #39495How?
We're essentially duplicating how Lodash's
isPlainObject()
works, in order to support objects withnull
prototype. Take a look at the tests to see what values we're expecting to betrue
andfalse
.If we all agree on this approach, I'm planning to work on a few more PRs to remove the rest of
isPlainObject()
including the custom inline versions I introduced in #41751.Testing Instructions