Skip to content

Commit c9d80d3

Browse files
committed
Block Support: Allow serialization skipping for ariaLabel
Allow skipping serialization for the `ariaLabel` block support. This enables applying the `aria-label` attribute to inner elements instead of the block wrapper. Follow-up to [59925]. Props mukesh27, wildworks. Fixes #64594. git-svn-id: https://develop.svn.wordpress.org/trunk@61671 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ff7564a commit c9d80d3

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/wp-includes/block-supports/aria-label.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ function wp_apply_aria_label_support( $block_type, $block_attributes ) {
4949
}
5050

5151
$has_aria_label_support = block_has_support( $block_type, array( 'ariaLabel' ), false );
52-
if ( ! $has_aria_label_support ) {
52+
if (
53+
! $has_aria_label_support ||
54+
wp_should_skip_block_supports_serialization( $block_type, 'ariaLabel' )
55+
) {
5356
return array();
5457
}
5558

tests/phpunit/tests/block-supports/aria-label.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ private function register_aria_label_block_with_support( $block_name, $supports
4444
}
4545

4646
/**
47-
* Tests that position block support works as expected.
47+
* Tests that aria-label block support works as expected.
4848
*
4949
* @ticket 62919
50+
* @ticket 64594
5051
*
5152
* @dataProvider data_aria_label_block_support
5253
*
5354
* @param boolean|array $support Aria label block support configuration.
5455
* @param string $value Aria label value for attribute object.
55-
* @param array $expected Expected aria label block support styles.
56+
* @param array $expected Expected aria-label attributes.
5657
*/
5758
public function test_wp_apply_aria_label_support( $support, $value, $expected ) {
5859
$block_type = self::register_aria_label_block_with_support(
@@ -82,6 +83,13 @@ public function data_aria_label_block_support() {
8283
'value' => 'Label',
8384
'expected' => array(),
8485
),
86+
'aria-label attribute is not applied when serialization is skipped' => array(
87+
'support' => array(
88+
'__experimentalSkipSerialization' => true,
89+
),
90+
'value' => 'Label',
91+
'expected' => array(),
92+
),
8593
);
8694
}
8795
}

0 commit comments

Comments
 (0)