Commit af7d3a10bc for wordpress.org
commit af7d3a10bc75e91fc28d42ea2d9d455ea9fdf761
Author: jonsurrell <jonsurrell@git.wordpress.org>
Date: Tue Nov 3 14:37:59 2026 +0000
Interactivity API: Remove event handler bind directives.
Server processing now removes `data-wp-bind--on*` directives from output.
Developed in: https://github.com/WordPress/wordpress-develop/pull/15396
Follow-up to r61885.
Props jonsurrell, ntsekouras, luisherranz.
See #66452.
Built from https://develop.svn.wordpress.org/trunk@65228
git-svn-id: http://core.svn.wordpress.org/trunk@64377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/interactivity-api/class-wp-interactivity-api.php b/wp-includes/interactivity-api/class-wp-interactivity-api.php
index 24bea55f8e..d8f11e2d05 100644
--- a/wp-includes/interactivity-api/class-wp-interactivity-api.php
+++ b/wp-includes/interactivity-api/class-wp-interactivity-api.php
@@ -1153,14 +1153,31 @@ final class WP_Interactivity_API {
* @since 7.1.0 An object is resolved to whatever it serializes to for the client, a number is formatted by the
* JSON encoder, and a value which cannot be sent to the client is rejected rather than passed to
* WP_HTML_Tag_Processor::set_attribute().
+ * @since 7.2.0 Event handler bind directives are removed.
*
* @param WP_Interactivity_API_Directives_Processor $p The directives processor instance.
* @param string $mode Whether the processing is entering or exiting the tag.
*/
private function data_wp_bind_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ): void {
if ( 'enter' === $mode ) {
- $entries = $this->get_directive_entries( $p, 'bind' );
+ $event_handler_prefix = 'data-wp-bind--on';
+ $entries = $this->get_directive_entries( $p, 'bind' );
foreach ( $entries as $entry ) {
+ // Binding event handler attributes is not supported.
+ if ( str_starts_with( $entry['attribute_name'], $event_handler_prefix ) ) {
+ $p->remove_attribute( $entry['attribute_name'] );
+ _doing_it_wrong(
+ __METHOD__,
+ sprintf(
+ /* translators: %s: The directive, e.g. data-wp-on--click. */
+ __( 'Binding event handler attributes is not supported. Please use "%s" instead.' ),
+ esc_attr( 'data-wp-on--' . substr( $entry['attribute_name'], strlen( $event_handler_prefix ) ) )
+ ),
+ '6.9.2'
+ );
+ continue;
+ }
+
if ( empty( $entry['suffix'] ) || null !== $entry['unique_id'] ) {
continue;
}
@@ -1183,20 +1200,6 @@ final class WP_Interactivity_API {
continue;
}
- // Skip if the suffix is an event handler.
- if ( str_starts_with( $entry['suffix'], 'on' ) ) {
- _doing_it_wrong(
- __METHOD__,
- sprintf(
- /* translators: %s: The directive, e.g. data-wp-on--click. */
- __( 'Binding event handler attributes is not supported. Please use "%s" instead.' ),
- esc_attr( 'data-wp-on--' . substr( $entry['suffix'], 2 ) )
- ),
- '6.9.2'
- );
- continue;
- }
-
$result = $this->evaluate( $entry );
/*
diff --git a/wp-includes/version.php b/wp-includes/version.php
index d422568822..2489f9e795 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta3-65227';
+$wp_version = '7.2-beta3-65228';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.