-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Lodash: Remove some _.get()
from Image block
#48489
Conversation
Size Change: +89 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
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.
LGTM, this all looks equivalent 👍 Great work, @tyxla!
@@ -192,7 +192,7 @@ export function ImageEdit( { | |||
|
|||
// If a caption text was meanwhile written by the user, | |||
// make sure the text is not overwritten by empty captions. | |||
if ( captionRef.current && ! get( mediaAttributes, [ 'caption' ] ) ) { | |||
if ( captionRef.current && ! mediaAttributes.caption ) { |
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.
mediaAttributes
is always an object.
99f6993
to
59b295a
Compare
Flaky tests detected in 59b295a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4283463250
|
What?
This PR removes Lodash's
_.get()
from the Image block.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 using optional chaining instead.
Testing Instructions
Smoke test the Image block, including an existing block, testing changing, deleting, and inserting a new image, changing image sizes and additional options, and verifying everything still works well.