Skip to content

Commit

Permalink
dont double escape
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 21, 2020
1 parent 8c4c106 commit 12ba0d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/Illuminate/View/Compilers/ComponentTagCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,8 @@ protected function componentString(string $component, array $attributes)
$parameters = $data->all();
}

$escapeAttributes = $class !== DynamicComponent::class;

return " @component('{$class}', '{$component}', [".$this->attributesToString($parameters, $escapeBound = false).'])
<?php $component->withAttributes(['.$this->attributesToString($attributes->all(), $escapeAttributes).']); ?>';
<?php $component->withAttributes(['.$this->attributesToString($attributes->all(), $escapeAttributes = $class !== DynamicComponent::class).']); ?>';
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/Illuminate/View/ComponentAttributeBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,15 @@ public function exceptProps($keys)
* Merge additional attributes / values into the attribute bag.
*
* @param array $attributeDefaults
* @param bool $escape
* @return static
*/
public function merge(array $attributeDefaults = [])
public function merge(array $attributeDefaults = [], $escape = true)
{
$attributes = [];

$attributeDefaults = array_map(function ($value) {
if (is_object($value) || is_null($value) || is_bool($value)) {
$attributeDefaults = array_map(function ($value) use ($escape) {
if (! $escape || is_object($value) || is_null($value) || is_bool($value)) {
return $value;
}

Expand Down Expand Up @@ -219,7 +220,7 @@ public function setAttributes(array $attributes)

unset($attributes['attributes']);

$attributes = $parentBag->merge($attributes)->getAttributes();
$attributes = $parentBag->merge($attributes, $escape = false)->getAttributes();
}

$this->attributes = $attributes;
Expand Down

0 comments on commit 12ba0d9

Please sign in to comment.