-
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 from blocks API raw handling #43575
Conversation
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, great work @tyxla! 👍
Left a minor suggestion.
@@ -39,7 +38,13 @@ function isFigureContent( node, schema ) { | |||
function canHaveAnchor( node, schema ) { | |||
const tag = node.nodeName.toLowerCase(); | |||
|
|||
return has( schema, [ 'figure', 'children', 'a', 'children', tag ] ); | |||
return ( |
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.
This is a bit unwieldy. How about:
return tag in ( schema?.figure?.children?.a?.children ?? {} )
?
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.
Clever suggestion - thanks 👍 I like it. Going to use it for both the has()
instances.
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.
Done in a95ce14
Size Change: +89 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
What?
This PR removes Lodash usage from the block the API for raw handling.
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 replacing all Lodash usage with native functionality.
Testing Instructions
npm run test:unit packages/blocks
npm run test:unit test/integration