Skip to content

Commit

Permalink
Temporarily pull in unstable__bootstrapServerSideBlockDefinitions for…
Browse files Browse the repository at this point in the history
… easier testing
  • Loading branch information
gwwar committed Feb 24, 2021
1 parent 9f2b026 commit 5df7ec4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/blocks/src/api/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,23 @@ export const serverSideBlockDefinitions = {};
// eslint-disable-next-line camelcase
export function unstable__bootstrapServerSideBlockDefinitions( definitions ) {
for ( const blockName of Object.keys( definitions ) ) {
// Don't overwrite if already set. It covers the case when metadata
// was initialized from the server.
if ( serverSideBlockDefinitions[ blockName ] ) {
// We still need to polyfill `apiVersion` for WordPress version
// lower than 5.7. If it isn't present in the definition shared
// from the server, we try to fallback to the definition passed.
// @see https://github.com/WordPress/gutenberg/pull/29279
if (
serverSideBlockDefinitions[ blockName ].apiVersion ===
undefined &&
definitions[ blockName ].apiVersion
) {
serverSideBlockDefinitions[ blockName ].apiVersion =
definitions[ blockName ].apiVersion;
}
continue;
}
serverSideBlockDefinitions[ blockName ] = mapKeys(
pickBy( definitions[ blockName ], ( value ) => ! isNil( value ) ),
( value, key ) => camelCase( key )
Expand Down

0 comments on commit 5df7ec4

Please sign in to comment.