Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8956f00475 | ||
|
|
dc15cf8463 | ||
|
|
1add9b421a |
No files matched your search
@@ -448,6 +448,11 @@ class HtmlBuilder
|
||||
$key = $value;
|
||||
}
|
||||
|
||||
// Treat boolean attributes as HTML properties
|
||||
if (is_bool($value)) {
|
||||
return $value ? $key : '';
|
||||
}
|
||||
|
||||
if (! is_null($value)) {
|
||||
return $key . '="' . e($value) . '"';
|
||||
}
|
||||
|
||||
@@ -115,4 +115,15 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('<a href="mailto:person@example.com" class="example-link"><span>First Name Last</span></a>', $result1);
|
||||
$this->assertEquals('<a href="mailto:person@example.com" class="example-link"><span>First Name Last</span></a>', $result2);
|
||||
}
|
||||
|
||||
public function testBooleanAttributes()
|
||||
{
|
||||
$result1 = $this->htmlBuilder->attributes(['my-property' => true]);
|
||||
|
||||
$result2 = $this->htmlBuilder->attributes(['my-property' => false]);
|
||||
|
||||
$this->assertEquals('my-property', trim($result1));
|
||||
|
||||
$this->assertEquals('', trim($result2));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user