-
-
Notifications
You must be signed in to change notification settings - Fork 22
Fix #234: Remove attribute sorting #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
a45c741
2c077f3
5dbeb8c
3cce673
5a7d751
7b99374
149ad61
cca3a4e
31b014e
12d0588
3a73eff
7c949b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,45 +96,6 @@ | |
| */ | ||
| final class Html | ||
| { | ||
| /** | ||
| * The preferred order of attributes in a tag. This mainly affects the order of the attributes that are | ||
| * rendered by {@see renderTagAttributes()}. | ||
| */ | ||
| private const ATTRIBUTE_ORDER = [ | ||
| 'type', | ||
| 'id', | ||
| 'class', | ||
| 'name', | ||
| 'value', | ||
|
|
||
| 'href', | ||
| 'loading', | ||
| 'src', | ||
| 'srcset', | ||
| 'form', | ||
| 'action', | ||
| 'method', | ||
|
|
||
| 'selected', | ||
| 'checked', | ||
| 'readonly', | ||
| 'disabled', | ||
| 'multiple', | ||
|
|
||
| 'size', | ||
| 'maxlength', | ||
| 'minlength', | ||
| 'width', | ||
| 'height', | ||
| 'rows', | ||
| 'cols', | ||
|
|
||
| 'alt', | ||
| 'title', | ||
| 'rel', | ||
| 'media', | ||
| ]; | ||
|
|
||
| /** | ||
| * List of tag attributes that should be specially handled when their values are of array type. | ||
| * In particular, if the value of the `data` attribute is `['name' => 'xyz', 'age' => 13]`, two attributes will be | ||
|
|
@@ -1613,16 +1574,6 @@ | |
| */ | ||
| public static function renderTagAttributes(array $attributes): string | ||
| { | ||
| if (count($attributes) > 1) { | ||
| $sorted = []; | ||
| foreach (self::ATTRIBUTE_ORDER as $name) { | ||
| if (isset($attributes[$name])) { | ||
| $sorted[$name] = $attributes[$name]; | ||
| } | ||
| } | ||
| $attributes = array_merge($sorted, $attributes); | ||
| } | ||
|
|
||
| $html = ''; | ||
| /** | ||
| * @var string $name | ||
|
|
@@ -1637,11 +1588,11 @@ | |
| /** @psalm-var array<array-key, scalar[]|string|Stringable|null> $value */ | ||
| foreach ($value as $n => $v) { | ||
| if (!isset($v)) { | ||
| continue; | ||
|
Check warning on line 1591 in src/Html.php
|
||
| } | ||
| $fullName = "$name-$n"; | ||
| if (in_array($fullName, self::ATTRIBUTES_WITH_CONCATENATED_VALUES, true)) { | ||
| $html .= self::renderAttribute( | ||
|
Check warning on line 1595 in src/Html.php
|
||
| $fullName, | ||
| self::encodeAttribute( | ||
| is_array($v) ? implode(' ', $v) : $v, | ||
|
|
@@ -1763,7 +1714,7 @@ | |
| } | ||
| } else { | ||
| /** @var string[] */ | ||
| $classes = preg_split('/\s+/', (string) $options['class'], -1, PREG_SPLIT_NO_EMPTY); | ||
|
Check warning on line 1717 in src/Html.php
|
||
| $classes = array_diff($classes, (array) $class); | ||
| if (empty($classes)) { | ||
| unset($options['class']); | ||
|
|
@@ -1914,7 +1865,7 @@ | |
| public static function cssStyleToArray(string|Stringable $style): array | ||
| { | ||
| $result = []; | ||
| foreach (explode(';', (string) $style) as $property) { | ||
|
Check warning on line 1868 in src/Html.php
|
||
| $property = explode(':', $property); | ||
| if (count($property) > 1) { | ||
| $result[trim($property[0])] = trim($property[1]); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.