diff --git a/src/LiveComponent/src/Util/LiveAttributesCollection.php b/src/LiveComponent/src/Util/LiveAttributesCollection.php index 21c9433be7e..64d6e7342a6 100644 --- a/src/LiveComponent/src/Util/LiveAttributesCollection.php +++ b/src/LiveComponent/src/Util/LiveAttributesCollection.php @@ -13,6 +13,7 @@ use Twig\Environment; use Twig\Extension\EscaperExtension; +use Twig\Runtime\EscaperRuntime; /** * An array of attributes that can eventually be returned as an escaped array. @@ -114,6 +115,10 @@ public function setQueryUrlMapping(array $queryUrlMapping): void private function escapeAttribute(string $value): string { + if (class_exists(EscaperRuntime::class)) { + return $this->twig->getRuntime(EscaperRuntime::class)->escape($value, 'html_attr'); + } + if (method_exists(EscaperExtension::class, 'escape')) { return EscaperExtension::escape($this->twig, $value, 'html_attr'); }