Skip to content
Snippets Groups Projects

Issue #3510596: Boolean prop with false value is not defined

@@ -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;
}
}
Loading