From cd945bd39c544f57c76b4a8d240df54535d51b49 Mon Sep 17 00:00:00 2001 From: Tom Cafferkey Date: Fri, 31 May 2024 08:42:35 +0100 Subject: [PATCH] Rename filename for classname fixes --- .../api/parser/apply-built-in-validation-fixes.js | 5 +---- .../{fix-custom-classname.js => fix-classnames.js} | 12 ++++++++++++ .../{fix-custom-classname.js => fix-classnames.js} | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) rename packages/blocks/src/api/parser/{fix-custom-classname.js => fix-classnames.js} (87%) rename packages/blocks/src/api/parser/test/{fix-custom-classname.js => fix-classnames.js} (98%) diff --git a/packages/blocks/src/api/parser/apply-built-in-validation-fixes.js b/packages/blocks/src/api/parser/apply-built-in-validation-fixes.js index 1b3e959eb9f16..c2228c09d1d39 100644 --- a/packages/blocks/src/api/parser/apply-built-in-validation-fixes.js +++ b/packages/blocks/src/api/parser/apply-built-in-validation-fixes.js @@ -1,10 +1,7 @@ /** * Internal dependencies */ -import { - fixCustomClassname, - fixVariationClassname, -} from './fix-custom-classname'; +import { fixCustomClassname, fixVariationClassname } from './fix-classnames'; /** * Attempts to fix block invalidation by applying build-in validation fixes diff --git a/packages/blocks/src/api/parser/fix-custom-classname.js b/packages/blocks/src/api/parser/fix-classnames.js similarity index 87% rename from packages/blocks/src/api/parser/fix-custom-classname.js rename to packages/blocks/src/api/parser/fix-classnames.js index 85bfd3293bad0..3db93c5efdf9e 100644 --- a/packages/blocks/src/api/parser/fix-custom-classname.js +++ b/packages/blocks/src/api/parser/fix-classnames.js @@ -71,6 +71,18 @@ export function fixCustomClassname( blockAttributes, blockType, innerHTML ) { return modifiedBlockAttributes; } +/** + * Given a block's attributes, block type settings, and innerHTML. If the block + * has variations and the active variation is not reflected in the block's + * markup, the active variation's class name is injected into the block's + * markup. + * + * @param {Object} blockAttributes Original block attributes. + * @param {Object} blockType Block type settings. + * @param {string} innerHTML Original block markup. + * + * @return {string} Block markup. + */ export function fixVariationClassname( blockAttributes, blockType, innerHTML ) { if ( hasBlockSupport( blockType, 'className', true ) ) { const activeVariation = getBlockTypeActiveVariation( diff --git a/packages/blocks/src/api/parser/test/fix-custom-classname.js b/packages/blocks/src/api/parser/test/fix-classnames.js similarity index 98% rename from packages/blocks/src/api/parser/test/fix-custom-classname.js rename to packages/blocks/src/api/parser/test/fix-classnames.js index 3715668d9e8d0..e9e5275920b12 100644 --- a/packages/blocks/src/api/parser/test/fix-custom-classname.js +++ b/packages/blocks/src/api/parser/test/fix-classnames.js @@ -4,7 +4,7 @@ import { fixCustomClassname, getHTMLRootElementClasses, -} from '../fix-custom-classname'; +} from '../fix-classnames'; describe( 'Fix custom className', () => { const blockSettings = {