Skip to content

Commit

Permalink
Ensure getThemeSupports is backward compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Nov 1, 2021
1 parent 2b8b304 commit dad9d2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/embed/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const EmbedEdit = ( props ) => {
return {
preview: validPreview ? embedPreview : undefined,
fetching: isRequestingEmbedPreview( attributesUrl ),
themeSupportsResponsive: getThemeSupports()?.[
themeSupportsResponsive: getThemeSupports()[
'responsive-embeds'
],
cannotEmbed: ! validPreview || previewIsFallback,
Expand Down
11 changes: 10 additions & 1 deletion packages/core-data/src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ import { getQueriedItems } from './queried-data';
import { DEFAULT_ENTITY_KEY } from './entities';
import { getNormalizedCommaSeparable, isRawAttribute } from './utils';

/**
* Shared reference to an empty object for cases where it is important to avoid
* returning a new object reference on every invocation, as in a connected or
* other pure component which performs `shouldComponentUpdate` check on props.
* This should be used as a last resort, since the normalized data should be
* maintained by the reducer result in state.
*/
const EMPTY_OBJECT = {};

/**
* Shared reference to an empty array for cases where it is important to avoid
* returning a new array reference on every invocation, as in a connected or
Expand Down Expand Up @@ -706,7 +715,7 @@ export function __experimentalGetCurrentGlobalStylesId( state ) {
* @return {*} Index data.
*/
export function getThemeSupports( state ) {
return getCurrentTheme( state )?.theme_supports;
return getCurrentTheme( state )?.theme_supports ?? EMPTY_OBJECT;
}

/**
Expand Down

0 comments on commit dad9d2b

Please sign in to comment.