Skip to content

Commit afb5af6

Browse files
committed
Update interactivity API click and async-click directive detection
1 parent a013a6d commit afb5af6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

includes/embeds/class-amp-core-block-handler.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -386,19 +386,19 @@ static function ( $matches ) use ( $modal_state_property, $is_interactive_block
386386
}
387387

388388
if ( $is_interactive_block ) {
389-
// Replace `data-wp-on--click` with AMP state on submenu open button.
389+
// Replace `data-wp-on--click` or `data-wp-on-async--click` with AMP state on submenu open button.
390390
if ( false !== strpos( $new_block_content, 'wp-block-navigation__responsive-container-open' ) ) {
391391
$new_block_content = preg_replace(
392-
'/\sdata-wp-on--click="[^"]+"/',
392+
'/\sdata-wp-on-(?:-click|async--click)="[^"]+"/',
393393
sprintf( ' on="tap:AMP.setState({ %1$s: !%1$s })"', esc_attr( $modal_state_property ) ),
394394
$new_block_content
395395
);
396396
}
397397

398-
// Replace `data-wp-on--click` with AMP state on submenu close button.
398+
// Replace `data-wp-on--click` or `data-wp-on-async--click` with AMP state on submenu close button.
399399
if ( false !== strpos( $new_block_content, 'wp-block-navigation__responsive-container-close' ) ) {
400400
$new_block_content = preg_replace(
401-
'/\sdata-wp-on--click="[^"]+"/',
401+
'/\sdata-wp-on-(?:-click|async--click)="[^"]+"/',
402402
sprintf( ' on="tap:AMP.setState({ %1$s: !%1$s })"', esc_attr( $modal_state_property ) ),
403403
$new_block_content
404404
);

0 commit comments

Comments
 (0)