Masterminds / Masterminds/html5-php
non boolean attributes
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 122
- PR merge metrics
- No merged PRs in 30d
Description
disable_html_ns was added to handle non-namespace aware tools. A common example in many usages of this lib:
XPath expressions will always fail because, e.g.
xmlns:p!=p
The problem with this config option:
Rules are defined for non-Boolean attributes to be output with ="" but these do not kick in when the disable_html_ns option is set.
What does the spec say?
Earlier versions of the HTML5 spec permitted the empty attribute syntax only for Boolean attributes. Later versions still don’t explicitly state that it is allowed for non-Boolean attributes, but they no longer say it is not (the specific clause, “This syntax is permitted only for boolean attributes,” has been removed).
validator.nu shows both <input disabled> and <input disabled=""> are valid (without namespace declarations).
Suggested changes
-
A config option to bypass the namespace tests and return return for anything listed in the
OutputRules::nonBooleanAttributes -
Based on the spec, the list if back to front. It should be listing attributes known as Boolean, rather than the other way round. Any unknown attribute should be classified as non-Boolean.
Item 1 above should be very simple to add and fully BC. Would you accept a PR for that?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/HTML5/Serializer/OutputRules.php around line 371 and trace how disable_html_ns affects non-Boolean attributes. Check the configuration path for adding the proposed namespace-test bypass. Done means the option is backward-compatible and allows listed non-Boolean attributes to serialize with an empty value when namespace handling is disabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100