Skip to content

Commit

Permalink
Revert "Fix block style selectors when root block selector is an elem…
Browse files Browse the repository at this point in the history
…ent"

This reverts commit 15270b6.
  • Loading branch information
aaronrobertshaw committed Jan 16, 2024
1 parent 15270b6 commit 6fb1cfb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,8 @@ protected static function get_blocks_metadata() {
foreach ( $registered_styles[ $block_name ] as $block_style ) {
if ( ! isset( $style_selectors[ $block_style['name'] ] ) ) {
$style_selectors[ $block_style['name'] ] = static::append_to_selector(
$block_metadata['selector'],
'.is-style-' . $block_style['name']
'.is-style-' . $block_style['name'],
$block_metadata['selector']
);
}
}
Expand Down Expand Up @@ -1065,14 +1065,14 @@ protected static function get_blocks_metadata() {
$style_selectors = array();
if ( ! empty( $block_type->styles ) ) {
foreach ( $block_type->styles as $style ) {
$style_selectors[ $style['name'] ] = static::append_to_selector( static::$blocks_metadata[ $block_name ]['selector'], '.is-style-' . $style['name'] );
$style_selectors[ $style['name'] ] = static::append_to_selector( '.is-style-' . $style['name'], static::$blocks_metadata[ $block_name ]['selector'] );
}
}

// Block style variations can be registered through the WP_Block_Styles_Registry as well as block.json.
$registered_styles = $style_registry->get_registered_styles_for_block( $block_name );
foreach ( $registered_styles as $style ) {
$style_selectors[ $style['name'] ] = static::append_to_selector( static::$blocks_metadata[ $block_name ]['selector'], '.is-style-' . $style['name'] );
$style_selectors[ $style['name'] ] = static::append_to_selector( '.is-style-' . $style['name'], static::$blocks_metadata[ $block_name ]['selector'] );
}

if ( ! empty( $style_selectors ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ export const getBlockSelectors = ( blockTypes, getBlockStyles ) => {
const styleVariationSelectors = {};

blockStyleVariations?.forEach( ( variation ) => {
const styleVariationSelector = `${ selector }.is-style-${ variation.name }`;
const styleVariationSelector = `.is-style-${ variation.name }${ selector }`;
styleVariationSelectors[ variation.name ] = styleVariationSelector;
} );

Expand Down

0 comments on commit 6fb1cfb

Please sign in to comment.