Review main Abandoned

76103[WIP][TASK] Allow arbitrary values in attributes

Benni Mack CR 0 V 0 Normal +97 −12 updated 04/21/26, 15:04

Commit message

GeneralUtility::implodeAttributes() can now properly
handle attributes without values, allowing "defer"
rather than "defer="defer"".

In addition, arrays and objects in attribute values,
are now serialized, if the option is set.

Review

  • Code review CR 0
  • Verified V 0
    • core-ci +1 CI

Files 5

Review log 1014

  1. Benni Mack uploaded patch set 1 10/12/22, 21:31

  2. core-ci voted on patch set 1 V -1 10/12/22, 21:42 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/32260

  3. Benni Mack uploaded patch set 2 10/13/22, 10:01

  4. core-ci voted on patch set 2 V -1 10/13/22, 10:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/32280

  5. Benni Mack uploaded patch set 3 10/13/22, 14:32

  6. core-ci voted on patch set 3 V -1 10/13/22, 14:40 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/32294

  7. Benni Mack uploaded patch set 4 10/14/22, 10:40

  8. core-ci voted on patch set 4 V +1 10/14/22, 10:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/32325

  9. Benni Mack marked it work in progress 03/24/23, 11:46

  10. Ayke Halder commented on patch set 4 06/10/24, 16:35

    Unresolved

    IMHO would go for this implementation: ```php [ 'nullattribute' => null, // don't render or render like empty string 'undefinedattribute' => undefined, // don't render 'trueattribute' => true, // render without value 'falseattribute' => false, // don't render ] ``` Result: ```html <tag trueattribute> ``` Alternative result: ```html <tag trueattribute nullattribute=""> ``` ---- Boolean HTMl attributes are not correctly implemented right now. * Boolean HTML attributes: https://developer.mozilla.org/en-US/docs/Glossary/Boolean/HTML > If the attribute is present, it can have one of the following values: > > * no value at all, e.g. attribute > * the empty string, e.g. attribute="" > * attribute's name itself, with no leading or trailing whitespace, e.g. attribute="attribute" > Note: The strings "true" and "false" are invalid values. To set the attribute to false, the attribute should not be present in the element tag. Though modern browsers treat any string value as true, you should not rely on that behavior.

    GeneralUtilityTest.php:1899 Unresolved

    `defer="true"` is wrong in context of Boolean HTML attributes. Should be one of * `<attribute defer>` * `<attribute defer="">` * `<attribute defer="defer">`
  11. Benni Mack abandoned the change 12/11/24, 14:37

    don't know what to do with this feedback, so I'm abandoning this one.
  12. Ayke Halder commented on patch set 4 12/11/24, 15:11

    @benni@typo3.org In case this is a question on the feedback - here is some detailed information. E.g. `defer` from the test-case is a 'boolean attribute': https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/defer https://www.w3.org/TR/2011/WD-html5-author-20110809/the-script-element.html#attr-script-defer Therefore it should be implemente as `<script defer>` or `<script defer="defer">` or `<script defer="">`. Currently it is implemented in the test-case as `<script defer="true">` About 'boolean html attribute' also see: https://developer.mozilla.org/en-US/docs/Glossary/Boolean/HTML https://www.w3.org/TR/2011/WD-html5-author-20110809/common-microsyntaxes.html#boolean-attribute > Note: The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.
  13. Ayke Halder commented on patch set 4 12/11/24, 15:23

  14. Ayke Halder commented on patch set 4 12/11/24, 19:49

    I implemented my feedback in: 87457: [WIP][TASK] Allow arbitrary values in attributes | https://review.typo3.org/c/Packages/TYPO3.CMS/+/87457 Patchset 1 is just a rebase: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87457/1 Patchsets 2 & 3 make Core CI happy: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87457/1..3 Patchset 4 implements a new attribute-value mapping as described in my comments on this issue here: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87457/3..4