Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Mar 15, 2024
1 parent 9e0d5f3 commit 4ce38d5
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,15 +572,21 @@ 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
* follows the exact same logic as Preact because it needs to
* 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 );
Expand Down

0 comments on commit 4ce38d5

Please sign in to comment.