Make WordPress Core


Ignore:
Timestamp:
05/30/2024 04:38:26 AM (2 years ago)
Author:
isabel_brison
Message:

Editor: Add scoping of feature level global styles selectors.

Ensures that feature-level selectors for block style variations are correctly scoped when generating a theme.json stylesheet.

Props aaronrobertshaw, audrasjb, vcanales, isabel_brison.
Fixes #61119.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme/wpThemeJson.php

    r58241 r58244  
    55905590                );
    55915591        }
     5592
     5593        /**
     5594         * Tests the correct scoping of selectors for a style node.
     5595         *
     5596         * @ticket 61119
     5597         */
     5598        public function test_scope_style_node_selectors() {
     5599                $theme_json = new ReflectionClass( 'WP_Theme_JSON' );
     5600
     5601                $func = $theme_json->getMethod( 'scope_style_node_selectors' );
     5602                $func->setAccessible( true );
     5603
     5604                $node = array(
     5605                        'name'      => 'core/image',
     5606                        'path'      => array( 'styles', 'blocks', 'core/image' ),
     5607                        'selector'  => '.wp-block-image',
     5608                        'selectors' => array(
     5609                                'root'       => '.wp-block-image',
     5610                                'border'     => '.wp-block-image img, .wp-block-image .wp-block-image__crop-area, .wp-block-image .components-placeholder',
     5611                                'typography' => array(
     5612                                        'textDecoration' => '.wp-block-image caption',
     5613                                ),
     5614                                'filter'     => array(
     5615                                        'duotone' => '.wp-block-image img, .wp-block-image .components-placeholder',
     5616                                ),
     5617                        ),
     5618                );
     5619
     5620                $actual   = $func->invoke( null, '.custom-scope', $node );
     5621                $expected = array(
     5622                        'name'      => 'core/image',
     5623                        'path'      => array( 'styles', 'blocks', 'core/image' ),
     5624                        'selector'  => '.custom-scope .wp-block-image',
     5625                        'selectors' => array(
     5626                                'root'       => '.custom-scope .wp-block-image',
     5627                                'border'     => '.custom-scope .wp-block-image img, .custom-scope .wp-block-image .wp-block-image__crop-area, .custom-scope .wp-block-image .components-placeholder',
     5628                                'typography' => array(
     5629                                        'textDecoration' => '.custom-scope .wp-block-image caption',
     5630                                ),
     5631                                'filter'     => array(
     5632                                        'duotone' => '.custom-scope .wp-block-image img, .custom-scope .wp-block-image .components-placeholder',
     5633                                ),
     5634                        ),
     5635                );
     5636
     5637                $this->assertEquals( $expected, $actual );
     5638        }
    55925639}
Note: See TracChangeset for help on using the changeset viewer.