Skip to content

Commit f98ae6d

Browse files
authored
getAttrsOutput helper for not escaping the attributes if the value is 0. (#473)
1 parent bd0e4bd commit f98ae6d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).
66

7+
## [11.0.3]
8+
9+
### Fixed
10+
11+
- `getAttrsOutput` helper for not escaping the attributes if the value is 0.
12+
713
## [11.0.2]
814

915
### Fixed
@@ -1060,6 +1066,7 @@ Init setup
10601066
- Gutenberg Blocks Registration.
10611067
- Assets Manifest data.
10621068

1069+
[11.0.3]: https://github.com/infinum/eightshift-libs/compare/11.0.2...11.0.3
10631070
[11.0.2]: https://github.com/infinum/eightshift-libs/compare/11.0.1...11.0.2
10641071
[11.0.1]: https://github.com/infinum/eightshift-libs/compare/11.0.0...11.0.1
10651072
[11.0.0]: https://github.com/infinum/eightshift-libs/compare/10.12.1...11.0.0

src/Helpers/AttributesTrait.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,12 @@ public static function getAttrsOutput(array $attrs, bool $escape = true): string
335335
$key = \esc_attr($key);
336336
}
337337

338-
if (empty($value)) {
339-
$htmlAttrs .= " {$key}";
340-
} else {
338+
if ($value == 0 || !empty($value)) { // intentional loose comparison to allow 0 values.
341339
$htmlAttrs .= " {$key}='{$value}'";
340+
continue;
342341
}
342+
343+
$htmlAttrs .= " {$key}";
343344
}
344345

345346
return $htmlAttrs;

0 commit comments

Comments
 (0)