Skip to content

Commit da9fcf4

Browse files
committed
Improve attribute name handling
Added: - Condition to trim leading and trailing whitespace from the array key. - Condition to ignore any empty array key.
1 parent 320b509 commit da9fcf4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Function.HTML-Build-Attributes.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ function html_build_attributes(array $attr, callable $callback = null)
2121
continue;
2222
}
2323

24+
if (is_string($key)) {
25+
$key = trim($key);
26+
27+
if (strlen($key) === 0) {
28+
continue;
29+
}
30+
}
31+
2432
if (is_object($val)) {
2533
if ($val instanceof Closure) {
2634
$val = $val();

0 commit comments

Comments
 (0)