Skip to content

Commit 8db386c

Browse files
committed
bug #1855 [LiveComponent] Fix EscaperRuntime deprecation (smnandre)
This PR was merged into the 2.x branch. Discussion ---------- [LiveComponent] Fix EscaperRuntime deprecation | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Issues | Fix # | License | MIT Fix deprecation Commits ------- 75516f0 [LiveComponent] Fix EscaperRuntime deprecation
2 parents 416753f + 75516f0 commit 8db386c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/LiveComponent/src/Util/LiveAttributesCollection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Twig\Environment;
1515
use Twig\Extension\EscaperExtension;
16+
use Twig\Runtime\EscaperRuntime;
1617

1718
/**
1819
* An array of attributes that can eventually be returned as an escaped array.
@@ -114,6 +115,10 @@ public function setQueryUrlMapping(array $queryUrlMapping): void
114115

115116
private function escapeAttribute(string $value): string
116117
{
118+
if (class_exists(EscaperRuntime::class)) {
119+
return $this->twig->getRuntime(EscaperRuntime::class)->escape($value, 'html_attr');
120+
}
121+
117122
if (method_exists(EscaperExtension::class, 'escape')) {
118123
return EscaperExtension::escape($this->twig, $value, 'html_attr');
119124
}

0 commit comments

Comments
 (0)