Skip to content

Commit

Permalink
Revert "[customize-widgets/utils/widgetToBlock] Initialize a widget…
Browse files Browse the repository at this point in the history
…'s `raw_content.content` to an empty string if it's `undefined`" (#46600)

* Revert "[`customize-widgets/utils/widgetToBlock`] Initialize a widget's `raw_content.content` to an empty string if it's `undefined` (#46487)"

This reverts commit 271f650.

* Guard against undefined content closer to parse() call
  • Loading branch information
noisysocks authored Dec 20, 2022
1 parent 0d5caa2 commit 4cc4c3c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/customize-widgets/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,12 @@ export function widgetToBlock( { id, idBase, number, instance } ) {
const {
encoded_serialized_instance: encoded,
instance_hash_key: hash,
raw_instance: rawInstance,
raw_instance: raw,
...rest
} = instance;

// It's unclear why `content` is sometimes `undefined`, but it shouldn't be.
const rawContent = rawInstance.content || '';
const raw = { ...rawInstance, content: rawContent };

if ( idBase === 'block' ) {
const parsedBlocks = parse( raw.content, {
const parsedBlocks = parse( raw.content ?? '', {
__unstableSkipAutop: true,
} );
block = parsedBlocks.length
Expand Down

1 comment on commit 4cc4c3c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3738092975
📝 Reported issues:

Please sign in to comment.