mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Update @wordpress packages
Update packages to include these bug fixes from Gutenberg: - Site Logo: Add option to set site icon from Site Logo block - Navigation: Enable even more compact setup state. - Remove template parts from post content inserter an __unstable filter - Template Editor Mode: Hide editor mode switcher - Avoid using CSS variables for block gap styles - Try to fix auto resizing in template part focus mode - Lower the specificity of font size CSS Custom Properties in the editor - Site icon: Fix site icon styling to display non-square site icons within a square button - [Site Editor]: Register block editor shortcuts - Update regex to handle 404 template slug - Site Editor: Remove dead code - [Block Editor]: Restrict delete multi selected blocks shortcut - Fix: Gradients are not being applied by class - Update: Make the global styles subtitles font smaller - Post Content/Title: Reflect changes when previewing post - ServerSideRender: Fix loading state - [Block Library]: Fix editable post blocks in Query Loop with zero queryId - Post Excerpt: Fix previews - WP59: Contextualize "Export" string to differentiate it from other occurrences in WP Core - Tools Panel: Fix race conditions caused by conditionally displayed ToolsPanelItems - ToolsPanel: Allow items to register when panelId is null - Font Size Picker: Allow non-integers as simple CSS values and in hints - [Components - FontSizePicker]: Use incremental sequence of numbers as labels for the available font-sizes at the segmented control (conditionally) See #54487. git-svn-id: https://develop.svn.wordpress.org/trunk@52434 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1,138 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @group block-supports
|
||||
*/
|
||||
class Tests_Block_Supports_Spacing extends WP_UnitTestCase {
|
||||
private $sample_block_content = '<div class="wp-block-test-block">Test</div>';
|
||||
private $test_gap_block_value = array();
|
||||
private $test_gap_block_args = array();
|
||||
|
||||
function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
$this->test_gap_block_value = array(
|
||||
'blockName' => 'test/test-block',
|
||||
'attrs' => array(
|
||||
'style' => array(
|
||||
'spacing' => array(
|
||||
'blockGap' => '3em',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->test_gap_block_args = array(
|
||||
'api_version' => 2,
|
||||
'supports' => array(
|
||||
'spacing' => array(
|
||||
'blockGap' => true,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
unregister_block_type( 'test/test-block' );
|
||||
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function test_spacing_gap_block_support_renders_block_inline_style() {
|
||||
register_block_type( 'test/test-block', $this->test_gap_block_args );
|
||||
$render_output = wp_render_spacing_gap_support(
|
||||
$this->sample_block_content,
|
||||
$this->test_gap_block_value
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'<div style="--wp--style--block-gap: 3em" class="wp-block-test-block">Test</div>',
|
||||
$render_output
|
||||
);
|
||||
}
|
||||
|
||||
function test_spacing_gap_block_support_renders_block_inline_style_with_inner_tag() {
|
||||
register_block_type( 'test/test-block', $this->test_gap_block_args );
|
||||
$render_output = wp_render_spacing_gap_support(
|
||||
'<div class="wp-test-block"><p style="color: red;">Test</p></div>',
|
||||
$this->test_gap_block_value
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'<div style="--wp--style--block-gap: 3em" class="wp-test-block"><p style="color: red;">Test</p></div>',
|
||||
$render_output
|
||||
);
|
||||
}
|
||||
|
||||
function test_spacing_gap_block_support_renders_block_inline_style_with_no_other_attributes() {
|
||||
register_block_type( 'test/test-block', $this->test_gap_block_args );
|
||||
$render_output = wp_render_spacing_gap_support(
|
||||
'<div><p>Test</p></div>',
|
||||
$this->test_gap_block_value
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'<div style="--wp--style--block-gap: 3em"><p>Test</p></div>',
|
||||
$render_output
|
||||
);
|
||||
}
|
||||
|
||||
function test_spacing_gap_block_support_renders_appended_block_inline_style() {
|
||||
register_block_type( 'test/test-block', $this->test_gap_block_args );
|
||||
$render_output = wp_render_spacing_gap_support(
|
||||
'<div class="wp-test-block" style="background: green;"><p style="color: red;">Test</p></div>',
|
||||
$this->test_gap_block_value
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'<div class="wp-test-block" style="--wp--style--block-gap: 3em; background: green;"><p style="color: red;">Test</p></div>',
|
||||
$render_output
|
||||
);
|
||||
}
|
||||
|
||||
function test_spacing_gap_block_support_does_not_render_style_when_support_is_false() {
|
||||
$this->test_gap_block_args['supports']['spacing']['blockGap'] = false;
|
||||
|
||||
register_block_type( 'test/test-block', $this->test_gap_block_args );
|
||||
$render_output = wp_render_spacing_gap_support(
|
||||
$this->sample_block_content,
|
||||
$this->test_gap_block_value
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->sample_block_content,
|
||||
$render_output
|
||||
);
|
||||
}
|
||||
|
||||
function test_spacing_gap_block_support_does_not_render_style_when_gap_is_null() {
|
||||
$this->test_gap_block_value['attrs']['style']['spacing']['blockGap'] = null;
|
||||
$this->test_gap_block_args['supports']['spacing']['blockGap'] = true;
|
||||
|
||||
register_block_type( 'test/test-block', $this->test_gap_block_args );
|
||||
$render_output = wp_render_spacing_gap_support(
|
||||
$this->sample_block_content,
|
||||
$this->test_gap_block_value
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->sample_block_content,
|
||||
$render_output
|
||||
);
|
||||
}
|
||||
|
||||
function test_spacing_gap_block_support_does_not_render_style_when_gap_is_illegal_value() {
|
||||
$this->test_gap_block_value['attrs']['style']['spacing']['blockGap'] = '" javascript="alert("hello");';
|
||||
$this->test_gap_block_args['supports']['spacing']['blockGap'] = true;
|
||||
|
||||
register_block_type( 'test/test-block', $this->test_gap_block_args );
|
||||
$render_output = wp_render_spacing_gap_support(
|
||||
$this->sample_block_content,
|
||||
$this->test_gap_block_value
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->sample_block_content,
|
||||
$render_output
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase
|
||||
'posts_per_page',
|
||||
'default_ping_status',
|
||||
'default_comment_status',
|
||||
'site_icon', // Registered in wp-includes/blocks/site-logo.php
|
||||
);
|
||||
|
||||
if ( ! is_multisite() ) {
|
||||
|
||||
@@ -419,18 +419,11 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
'spacing' => array(
|
||||
'blockGap' => '1em',
|
||||
),
|
||||
'blocks' => array(
|
||||
'core/columns' => array(
|
||||
'spacing' => array(
|
||||
'blockGap' => '24px',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$expected = 'body { margin: 0; }body{--wp--style--block-gap: 1em;}.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; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }.wp-block-columns{--wp--style--block-gap: 24px;}';
|
||||
$expected = 'body { margin: 0; }body{--wp--style--block-gap: 1em;}.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; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }';
|
||||
$this->assertSame( $expected, $theme_json->get_stylesheet() );
|
||||
$this->assertSame( $expected, $theme_json->get_stylesheet( array( 'styles' ) ) );
|
||||
}
|
||||
@@ -2348,4 +2341,47 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
$this->assertEqualSetsWithIndex( $expected, $actual['settings']['spacing'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 54487
|
||||
*/
|
||||
public function test_sanitization() {
|
||||
$theme_json = new WP_Theme_JSON(
|
||||
array(
|
||||
'version' => 2,
|
||||
'styles' => array(
|
||||
'spacing' => array(
|
||||
'blockGap' => 'valid value',
|
||||
),
|
||||
'blocks' => array(
|
||||
'core/group' => array(
|
||||
'spacing' => array(
|
||||
'margin' => 'valid value',
|
||||
'blockGap' => 'invalid value',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$actual = $theme_json->get_raw_data();
|
||||
$expected = array(
|
||||
'version' => 2,
|
||||
'styles' => array(
|
||||
'spacing' => array(
|
||||
'blockGap' => 'valid value',
|
||||
),
|
||||
'blocks' => array(
|
||||
'core/group' => array(
|
||||
'spacing' => array(
|
||||
'margin' => 'valid value',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEqualSetsWithIndex( $expected, $actual );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user