From 4ce38d57d94a63bf383be1f93aa03e1644a6b1e7 Mon Sep 17 00:00:00 2001 From: Jon Surrell <sirreal@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:09:29 +0100 Subject: [PATCH] Port https://github.com/WordPress/wordpress-develop/pull/6257 --- .../interactivity-api/class-wp-interactivity-api.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/compat/wordpress-6.5/interactivity-api/class-wp-interactivity-api.php b/lib/compat/wordpress-6.5/interactivity-api/class-wp-interactivity-api.php index 1fc757accf6f6b..ce90f90c74d930 100644 --- a/lib/compat/wordpress-6.5/interactivity-api/class-wp-interactivity-api.php +++ b/lib/compat/wordpress-6.5/interactivity-api/class-wp-interactivity-api.php @@ -572,7 +572,10 @@ private function data_wp_bind_processor( WP_Interactivity_API_Directives_Process $attribute_value = $p->get_attribute( $attribute_name ); $result = $this->evaluate( $attribute_value, end( $namespace_stack ), end( $context_stack ) ); - if ( null !== $result && ( false !== $result || '-' === $bound_attribute[4] ) ) { + if ( null !== $result && ( + false !== $result || + ( strlen( $bound_attribute ) > 5 && '-' === $bound_attribute[4] ) + ) ) { /* * If the result of the evaluation is a boolean and the attribute is * `aria-` or `data-, convert it to a string "true" or "false". It @@ -580,7 +583,10 @@ private function data_wp_bind_processor( WP_Interactivity_API_Directives_Process * replicate what Preact will later do in the client: * https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L131C24-L136 */ - if ( is_bool( $result ) && '-' === $bound_attribute[4] ) { + if ( + is_bool( $result ) && + ( strlen( $bound_attribute ) > 5 && '-' === $bound_attribute[4] ) + ) { $result = $result ? 'true' : 'false'; } $p->set_attribute( $bound_attribute, $result );