Fix #17793: Fix inconsistent handling of null data attribute values in yii\helpers\BaseHtml::renderTagAttributes()

This commit is contained in:
Brandon Kelly
2020-01-10 10:35:09 -08:00
committed by Alexander Makarov
parent 7e471e3010
commit beca7b45d3
3 changed files with 10 additions and 1 deletions

View File

@ -12,6 +12,7 @@ Yii Framework 2 Change Log
- Bug #12539: `yii\filters\ContentNegotiator` now generates 406 'Not Acceptable' instead of 415 'Unsupported Media Type' on content-type negotiation fail (PowerGamer1) - Bug #12539: `yii\filters\ContentNegotiator` now generates 406 'Not Acceptable' instead of 415 'Unsupported Media Type' on content-type negotiation fail (PowerGamer1)
- Bug #17760: Fix `JSON::encode()` for `\DateTimeInterface` under PHP 7.4 (samdark) - Bug #17760: Fix `JSON::encode()` for `\DateTimeInterface` under PHP 7.4 (samdark)
- Enh #17792: Added support for `aria` attributes to `yii\helpers\BaseHtml::renderTagAttributes()` (brandonkelly) - Enh #17792: Added support for `aria` attributes to `yii\helpers\BaseHtml::renderTagAttributes()` (brandonkelly)
- Bug #17793: Fix inconsistent handling of null `data` attribute values in `yii\helpers\BaseHtml::renderTagAttributes()` (brandonkelly)
2.0.31 December 18, 2019 2.0.31 December 18, 2019

View File

@ -1961,7 +1961,7 @@ class BaseHtml
if ($v) { if ($v) {
$html .= " $name-$n"; $html .= " $name-$n";
} }
} else { } elseif ($v !== null) {
$html .= " $name-$n=\"" . static::encode($v) . '"'; $html .= " $name-$n=\"" . static::encode($v) . '"';
} }
} }

View File

@ -1028,6 +1028,14 @@ EOD;
], ],
]; ];
$this->assertEquals('', Html::renderTagAttributes($attributes)); $this->assertEquals('', Html::renderTagAttributes($attributes));
$attributes = [
'data' => [
'foo' => null,
],
];
$this->assertEquals('', Html::renderTagAttributes($attributes));
} }
public function testAddCssClass() public function testAddCssClass()