8000 [TwigComponent] Fix escaping stimulus attributes · symfony/stimulus-bundle@68ce084 · GitHub
[go: up one dir, main page]

Skip to content

Commit 68ce084

Browse files
committed
[TwigComponent] Fix escaping stimulus attributes
1 parent 647392b commit 68ce084

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Dto/StimulusAttributes.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ public function toArray(): array
179179
return array_merge($attributes, $this->attributes);
180180
}
181181

182+
public function toEscapedArray(): array
183+
{
184+
$escaped = [];
185+
foreach ($this->toArray() as $key => $value) {
186+
$escaped[$key] = $this->escapeAsHtmlAttr($value);
187+
}
188+
189+
return $escaped;
190+
}
191+
182192
private function getFormattedValue(mixed $value): string
183193
{
184194
if ($value instanceof \Stringable || (\is_object($value) && \is_callable([$value, '__toString']))) {

0 commit comments

Comments
 (0)
0