Skip to content

Commit cea6952

Browse files
aeonscrynobone
authored andcommitted
Support boolean html attributes
http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#boolean-attributes Signed-off-by: crynobone <crynobone@gmail.com>
1 parent 95bf213 commit cea6952

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/HtmlBuilder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,12 @@ public function attributes($attributes)
418418
*/
419419
protected function attributeElement($key, $value)
420420
{
421-
is_numeric($key) && $key = $value;
421+
// For numeric keys we will assume that the value is a boolean attribute
422+
// where the presence of the attribute represents a true value and the
423+
// absence represents a false value.
424+
if (is_numeric($key)) {
425+
return $value;
426+
}
422427

423428
if (! is_null($value)) {
424429
return $key.'="'.e($value).'"';

0 commit comments

Comments
 (0)