mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Editor: Fix Theme.json application of custom root selector for styles.
Theme.json stylesheets attempting to use a custom root selector are generated with in correct styles. Props aaronrobertshaw, get_dave, mukesh27. Fixes #60343. git-svn-id: https://develop.svn.wordpress.org/trunk@57352 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b617b5c79a
commit
5bd13e7cc1
@ -935,7 +935,7 @@ class WP_Theme_JSON {
|
||||
|
||||
if ( $duotone_support ) {
|
||||
$root_selector = wp_get_block_css_selector( $block_type );
|
||||
$duotone_selector = WP_Theme_JSON::scope_selector( $root_selector, $duotone_support );
|
||||
$duotone_selector = static::scope_selector( $root_selector, $duotone_support );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1078,7 +1078,7 @@ class WP_Theme_JSON {
|
||||
$setting_nodes[ $root_settings_key ]['selector'] = $options['root_selector'];
|
||||
}
|
||||
if ( false !== $root_style_key ) {
|
||||
$setting_nodes[ $root_style_key ]['selector'] = $options['root_selector'];
|
||||
$style_nodes[ $root_style_key ]['selector'] = $options['root_selector'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3210,7 +3210,6 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
*
|
||||
* @param array $styles An array with style definitions.
|
||||
* @param array $path Path to the desired properties.
|
||||
*
|
||||
*/
|
||||
public function test_get_property_value_should_return_string_for_invalid_paths_or_null_values( $styles, $path ) {
|
||||
$reflection_class = new ReflectionClass( WP_Theme_JSON::class );
|
||||
@ -4939,4 +4938,33 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
$this->assertEquals( $small_font, $styles['blocks']['core/quote']['variations']['plain']['typography']['fontSize'], 'Block variations: font-size' );
|
||||
$this->assertEquals( $secondary_color, $styles['blocks']['core/quote']['variations']['plain']['color']['background'], 'Block variations: color' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a custom root selector is correctly applied when generating a stylesheet.
|
||||
*
|
||||
* @ticket 60343
|
||||
*/
|
||||
public function test_get_stylesheet_custom_root_selector() {
|
||||
$theme_json = new WP_Theme_JSON(
|
||||
array(
|
||||
'version' => WP_Theme_JSON::LATEST_SCHEMA,
|
||||
'styles' => array(
|
||||
'color' => array(
|
||||
'text' => 'teal',
|
||||
),
|
||||
),
|
||||
),
|
||||
'default'
|
||||
);
|
||||
|
||||
$options = array( 'root_selector' => '.custom' );
|
||||
$actual = $theme_json->get_stylesheet( array( 'styles' ), null, $options );
|
||||
|
||||
// Results also include root site blocks styles which hard code
|
||||
// `body { margin: 0;}`.
|
||||
$this->assertEquals(
|
||||
'body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.custom{color: teal;}',
|
||||
$actual
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user