diff --git a/docs/how-to-guides/themes/theme-json.md b/docs/how-to-guides/themes/theme-json.md index 6c0b2392e22bbb..32f9bacacefc5e 100644 --- a/docs/how-to-guides/themes/theme-json.md +++ b/docs/how-to-guides/themes/theme-json.md @@ -91,7 +91,7 @@ To address this need, we've started to experiment with CSS Custom Properties, ak {% Output %} ```css -:root { +body { --wp--preset--color--black: #000000; --wp--preset--color--white: #ffffff; } @@ -122,7 +122,7 @@ To address this need, we've started to experiment with CSS Custom Properties, ak {% Output %} ```css -:root { +body { --wp--custom--line-height--body: 1.7; --wp--custom--line-height--heading: 1.3; } @@ -292,7 +292,7 @@ For example: {% Output %} ```css -:root { +body { --wp--preset--color--strong-magenta: #a156b4; --wp--preset--color--very-dark-gray: #444; --wp--preset--font-size--big: 32; @@ -344,7 +344,7 @@ For example: {% Output %} ```css -:root { +body { --wp--custom--base-font: 16; --wp--custom--line-height--small: 1.2; --wp--custom--line-height--medium: 1.4; @@ -434,7 +434,7 @@ For example: {% Output %} ```css -:root { +body { color: var( --wp--preset--color--primary ); } h1 { @@ -549,7 +549,7 @@ For example: {% Output %} ```css -:root { +body { --wp--custom--line-height--body: 1.7; --wp--custom--font-primary: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif"; } diff --git a/lib/class-wp-theme-json.php b/lib/class-wp-theme-json.php index 871cb9c1c68f5f..95447a0946358d 100644 --- a/lib/class-wp-theme-json.php +++ b/lib/class-wp-theme-json.php @@ -39,7 +39,7 @@ class WP_Theme_JSON { * * @var string */ - const ALL_BLOCKS_SELECTOR = ':root'; + const ALL_BLOCKS_SELECTOR = 'body'; /** * How to address the root block @@ -54,7 +54,7 @@ class WP_Theme_JSON { * * @var string */ - const ROOT_BLOCK_SELECTOR = ':root'; + const ROOT_BLOCK_SELECTOR = 'body'; const VALID_TOP_LEVEL_KEYS = array( 'customTemplates', @@ -356,7 +356,7 @@ private static function to_property( $css_name ) { * * { * 'root': { - * 'selector': ':root' + * 'selector': 'body' * }, * 'core/heading/h1': { * 'selector': 'h1' diff --git a/packages/edit-site/src/components/editor/utils.js b/packages/edit-site/src/components/editor/utils.js index b66725dbe647c5..b695c102ef1c60 100644 --- a/packages/edit-site/src/components/editor/utils.js +++ b/packages/edit-site/src/components/editor/utils.js @@ -13,9 +13,9 @@ import { store as editSiteStore } from '../../store'; /* Supporting data */ export const ALL_BLOCKS_NAME = 'defaults'; -export const ALL_BLOCKS_SELECTOR = ':root'; +export const ALL_BLOCKS_SELECTOR = 'body'; export const ROOT_BLOCK_NAME = 'root'; -export const ROOT_BLOCK_SELECTOR = ':root'; +export const ROOT_BLOCK_SELECTOR = 'body'; export const ROOT_BLOCK_SUPPORTS = [ '--wp--style--color--link', 'background', diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index 09ad612357c73a..372f6c7a7ba551 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -108,15 +108,15 @@ function test_get_stylesheet() { ); $this->assertEquals( - ':root{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}:root{--wp--style--color--link: #111;color: var(--wp--preset--color--grey);}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.has-grey-color{color: grey !important;}.has-grey-background-color{background-color: grey !important;}.has-grey-border-color{border-color: grey !important;}', + 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}body{--wp--style--color--link: #111;color: var(--wp--preset--color--grey);}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.has-grey-color{color: grey !important;}.has-grey-background-color{background-color: grey !important;}.has-grey-border-color{border-color: grey !important;}', $theme_json->get_stylesheet() ); $this->assertEquals( - ':root{--wp--style--color--link: #111;color: var(--wp--preset--color--grey);}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.has-grey-color{color: grey !important;}.has-grey-background-color{background-color: grey !important;}.has-grey-border-color{border-color: grey !important;}', + 'body{--wp--style--color--link: #111;color: var(--wp--preset--color--grey);}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.has-grey-color{color: grey !important;}.has-grey-background-color{background-color: grey !important;}.has-grey-border-color{border-color: grey !important;}', $theme_json->get_stylesheet( 'block_styles' ) ); $this->assertEquals( - ':root{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}', + 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}', $theme_json->get_stylesheet( 'css_variables' ) ); } @@ -187,7 +187,7 @@ public function test_get_stylesheet_preset_values_are_marked_as_important() { ); $this->assertEquals( - ':root{--wp--preset--color--grey: grey;}h2.wp-block-post-title{background-color: blue;color: red;font-size: 12px;line-height: 1.3;}.has-grey-color{color: grey !important;}.has-grey-background-color{background-color: grey !important;}.has-grey-border-color{border-color: grey !important;}', + 'body{--wp--preset--color--grey: grey;}h2.wp-block-post-title{background-color: blue;color: red;font-size: 12px;line-height: 1.3;}.has-grey-color{color: grey !important;}.has-grey-background-color{background-color: grey !important;}.has-grey-border-color{border-color: grey !important;}', $theme_json->get_stylesheet() ); }