Make WordPress Core


Ignore:
Timestamp:
03/15/2024 11:15:56 AM (14 months ago)
Author:
swissspidy
Message:

Interactivity API: Prevent warning when using a bind directive with a short attribute name.

Adds new tests and improves existing ones by using assertSame to do type comparison as well.

Reviewed by gziolo.
Merges [57835] to the to the 6.5 branch.

Props jonsurrell, cbravobernal, swissspidy, gziolo.
Fixes #60758.

Location:
branches/6.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.5

  • branches/6.5/src/wp-includes/interactivity-api/class-wp-interactivity-api.php

    r57834 r57837  
    592592                $result          = $this->evaluate( $attribute_value, end( $namespace_stack ), end( $context_stack ) );
    593593
    594                 if ( null !== $result && ( false !== $result || '-' === $bound_attribute[4] ) ) {
     594                if (
     595                    null !== $result &&
     596                    (
     597                        false !== $result ||
     598                        ( strlen( $bound_attribute ) > 5 && '-' === $bound_attribute[4] )
     599                    )
     600                ) {
    595601                    /*
    596602                     * If the result of the evaluation is a boolean and the attribute is
     
    600606                     * https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L131C24-L136
    601607                     */
    602                     if ( is_bool( $result ) && '-' === $bound_attribute[4] ) {
     608                    if (
     609                        is_bool( $result ) &&
     610                        ( strlen( $bound_attribute ) > 5 && '-' === $bound_attribute[4] )
     611                    ) {
    603612                        $result = $result ? 'true' : 'false';
    604613                    }
Note: See TracChangeset for help on using the changeset viewer.