From ea037cf933851f6a1b22f1f8db669b463a413ad2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabien=20Cl=C3=A9ment?=
 <15911-goz@users.noreply.drupalcode.org>
Date: Mon, 3 Mar 2025 08:27:40 +0000
Subject: [PATCH 1/2] Issue #3510596: Boolean prop with false value is not
 defined

---
 src/Element/ComponentElementBuilder.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/Element/ComponentElementBuilder.php b/src/Element/ComponentElementBuilder.php
index e2948b34..090f462a 100644
--- a/src/Element/ComponentElementBuilder.php
+++ b/src/Element/ComponentElementBuilder.php
@@ -98,7 +98,7 @@ class ComponentElementBuilder implements TrustedCallbackInterface {
       }
     }
     else {
-      if (!empty($data) || $prop_type->getPluginId() === 'attributes') {
+      if (empty($data) && !in_array($prop_type->getPluginId(), ['attributes', 'boolean'])) {
         // For JSON Schema validator, empty value is not the same as missing
         // value, and we want to prevent some of the prop types rules to be
         // applied on empty values: string pattern, string format,
@@ -106,6 +106,8 @@ class ComponentElementBuilder implements TrustedCallbackInterface {
         // However, we don't remove empty attributes to avoid an error with
         // Drupal\Core\Template\TwigExtension::createAttribute() when themers
         // forget to use the default({}) filter.
+        // We do not remove empty value for boolean neither, because false is
+        // considered as empty, which is wrong.
         $build['#props'][$prop_or_slot_id] = $data;
       }
     }
-- 
GitLab


From 0d1024b62a97902bbcbc17d3cd3cc5330cb25d36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabien=20Cl=C3=A9ment?=
 <15911-goz@users.noreply.drupalcode.org>
Date: Mon, 24 Mar 2025 09:55:15 +0000
Subject: [PATCH 2/2] Fix condition, wrong condition when rebasing

---
 src/Element/ComponentElementBuilder.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Element/ComponentElementBuilder.php b/src/Element/ComponentElementBuilder.php
index 090f462a..657c456f 100644
--- a/src/Element/ComponentElementBuilder.php
+++ b/src/Element/ComponentElementBuilder.php
@@ -98,7 +98,7 @@ class ComponentElementBuilder implements TrustedCallbackInterface {
       }
     }
     else {
-      if (empty($data) && !in_array($prop_type->getPluginId(), ['attributes', 'boolean'])) {
+      if (!empty($data) || in_array($prop_type->getPluginId(), ['attributes', 'boolean'])) {
         // For JSON Schema validator, empty value is not the same as missing
         // value, and we want to prevent some of the prop types rules to be
         // applied on empty values: string pattern, string format,
-- 
GitLab