Skip to content

Commit

Permalink
Prevent already migrated blocks re-migrating
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Mar 15, 2023
1 parent 92b6c9b commit 295ca16
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/block-library/src/media-text/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,20 @@ const v6 = {
);
},
migrate: migrateDefaultAlign,
isEligible( attributes ) {
return attributes.align === undefined;
isEligible( attributes, innerBlocks, { block } ) {
const { attributes: finalizedAttributes } = block;
// When the align attribute is switched to default to none, valid
// block markup wouldn't contain any alignment CSS class. Unfortunately,
// this deprecation's version of the block won't be invalidated due to
// the alignwide class still being in the markup. That is because the
// custom CSS classname support picks it up and adds it to the className
// attribute. At the time of parsing, the className attribute won't
// contain the alignwide class, hence the need to check the finalized
// block attributes.
return (
attributes.align === undefined &&
!! finalizedAttributes.className?.includes( 'alignwide' )
);
},
};

Expand Down

0 comments on commit 295ca16

Please sign in to comment.