Skip to content
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

non boolean attributes #184

Open
bytestream opened this issue May 31, 2020 · 2 comments
Open

non boolean attributes #184

bytestream opened this issue May 31, 2020 · 2 comments

Comments

@bytestream
Copy link
Contributor

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.

protected function nonBooleanAttribute(\DOMAttr $attr)

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

  1. A config option to bypass the namespace tests and return return for anything listed in the OutputRules::nonBooleanAttributes

  2. 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?

@goetas
Copy link
Member

goetas commented Jun 3, 2020

I hope to understand correctly, but your goal is to be able to define boolean attributes even when namespacing is disabled, right? (by probably having a list of tags with allowed boolean attributes, right?

@bytestream
Copy link
Contributor Author

The goal is to be able to output ="" when no namespace is specified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants