PluginProbe
Gutenberg / 24.0.0
Gutenberg v24.0.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/scripts/block-library/tab-panel.php +14 -5 23.5.224.0.0 View file →
@@ -21,12 +21,12 @@
21 21
22 22 static $tab_counters = array();
23 23
24 24 if ( ! isset( $tab_counters[ $tabs_id ] ) ) {
25 - $tab_counters[ $tabs_id ] = 0;
25 + $tab_counters[ $tabs_id ] = 1;
26 26 }
27 27
28 - $tab_index = $tab_counters[ $tabs_id ];
28 + $tab_number = $tab_counters[ $tabs_id ];
29 29 ++$tab_counters[ $tabs_id ];
30 30
31 31 $tag_processor = new WP_HTML_Tag_Processor( $content );
32 32 $tag_processor->next_tag( array( 'class_name' => 'wp-block-tab-panel' ) );
@@ -35,15 +35,24 @@
35 35 // the generated position-based ID.
36 36 $tab_id = (string) $tag_processor->get_attribute( 'id' );
37 37 if ( empty( $tab_id ) ) {
38 38 $tab_id = ! empty( $tabs_id )
39 - ? $tabs_id . '-tab-' . $tab_index
40 - : 'tab-' . $tab_index;
39 + ? $tabs_id . '-tab-' . $tab_number
40 + : 'tab-' . $tab_number;
41 41 $tag_processor->set_attribute( 'id', $tab_id );
42 42 }
43 43
44 44 $tag_processor->set_attribute( 'aria-labelledby', 'tab__' . $tab_id );
45 - $tag_processor->set_attribute( 'data-wp-bind--hidden', '!state.isActiveTab' );
45 +
46 + /*
47 + * Hiding a panel is left to the client, which is why `hidden` is bound to a
48 + * state getter the server cannot resolve rather than set here: a visitor
49 + * whose browser never runs the block's script is then given the content of
50 + * every panel instead of none of it. `core/accordion` works the same way.
51 + */
52 + $tag_processor->set_attribute( 'data-wp-bind--hidden', 'state.isHidden' );
53 + $tag_processor->set_attribute( 'data-wp-bind--tabindex', 'state.tabIndexAttribute' );
54 + $tag_processor->set_attribute( 'data-wp-on--beforematch', 'actions.handleBeforeMatch' );
46 55
47 56 return (string) $tag_processor->get_updated_html();
48 57 }
49 58