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

data-* attribute giving "Unknown HTML attribute(s)" #11

Closed
meowcakes opened this issue May 19, 2015 · 6 comments
Closed

data-* attribute giving "Unknown HTML attribute(s)" #11

meowcakes opened this issue May 19, 2015 · 6 comments

Comments

@meowcakes
Copy link

Hello,

When using the :attr option on, for example, a h-box, the validator will complain that it is not valid HTML when using a data-* attribute. This should not be the case as this is a HTML5 standard. The same would apply to aria-* attributes.

Thank you

@Gregg8
Copy link
Contributor

Gregg8 commented May 21, 2015

Yes, you are certainly correct about both of those attributes. I will not be able to get an opportunity to work on this for a while. If you end up making the changes yourself, we'd be happy to incorporate your code.

@meowcakes
Copy link
Author

Hi, I began working on a pull request and while doing so I ran into the problem of validating XML attribute names. According to the W3 spec here http://www.w3.org/TR/2011/WD-html5-20110525/elements.html#embedding-custom-non-visible-data-with-the-data-attributes the data-* attribute has to be a valid XML attribute name (not surprising, I guess). I tried implementing the naming spec here http://www.w3.org/TR/REC-xml/#NT-Name using a regular expression, but then found it was exceptionally painful due to JavaScript's poor support for Unicode characters in regular expressions. I could implement it without using a regular expression, but I thought it might be a good idea to ask whether you think it's even worth it to do so, or is it good enough to just make sure the the attribute starts with data- and has one or more characters after that?

Thanks, and apologies for the bikeshedding

@mike-thompson-day8
Copy link
Contributor

The goal with this validation is to help a programmer catch problems early. Misspelling something can take a surprisingly long time to find sometimes.

So we want to be as helpful as we can be, but not tie ourselves in knots doing it ;-)

In which case, I think checking for data-* and waving it through as vailid is fine by me.

@mike-thompson-day8
Copy link
Contributor

@meowcakes checking: given you have closed this, are you then working on a patch to wave data-* through as valid?

@meowcakes
Copy link
Author

Yup, pull request opened here #13

@mike-thompson-day8
Copy link
Contributor

Thanks!

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

3 participants