Skip to content

Commit

Permalink
Comment conditional loading
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 25, 2023
1 parent f8904e1 commit 1b3b9be
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,18 @@ function render_block_core_navigation( $attributes, $content, $block ) {
$should_load_view_script = ( $is_responsive_menu || $attributes['openSubmenusOnClick'] || $attributes['showSubmenuIcon'] );
$view_js_file = 'wp-block-navigation-view';
// If the script already exists, there is no point in removing it from viewScript.
if ( ! wp_script_is( $view_js_file ) ) {
$script_handles = $block->block_type->view_script_handles;

// If the script is not needed, and it is still in the `view_script_handles`, remove it.
if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
}
// If the script is needed, but it was previously removed, add it again.
if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
}
}
// if ( ! wp_script_is( $view_js_file ) ) {
// $script_handles = $block->block_type->view_script_handles;

// // If the script is not needed, and it is still in the `view_script_handles`, remove it.
// if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
// $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
// }
// // If the script is needed, but it was previously removed, add it again.
// if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
// $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
// }
// }

$inner_blocks = $block->inner_blocks;

Expand Down

0 comments on commit 1b3b9be

Please sign in to comment.