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. Props jonsurrell, cbravobernal, swissspidy, gziolo. Fixes #60758. Built from https://develop.svn.wordpress.org/trunk@57835 git-svn-id: http://core.svn.wordpress.org/trunk@57336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cca720266b
commit
78ea9f4ee6
|
@ -591,7 +591,13 @@ final class WP_Interactivity_API {
|
|||
$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
|
||||
|
@ -599,7 +605,10 @@ final class WP_Interactivity_API {
|
|||
* 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 );
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.6-alpha-57833';
|
||||
$wp_version = '6.6-alpha-57835';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue