-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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 does not support number
#2329
Comments
While most browsers tend to parse data attributes starting with a number, it is actually not valid according to W3. The most likely reason being that See: Closing, reopen if you disagree. |
I've read the two links you've posted and I'm not sure where exactly the spec disallows numbers.
Let's see what "XML-compatible" means (quoting http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#xml-compatible)
What is the "Name production"? This is where your second links comes in, the EBNF rules for "Name". It's correct that That being said, |
It's valid. We forced some stricter guidelines than the spec does because we thought the spec was poor and we wanted people to have better practices. There may have been some issues with browser support earlier but I can't recall. Anyway, the choice hasn't been a real problem before. But we're more popular now and should make spec-compatible things work unless we have something better. Hopefully we'll make |
One place where I think we'll keep deviating is the allowance of upper case data attrs in html. as noted in the link they get lowercased by parsing rules anyway so they're technically fine to use, but it's confusing behavior going from JS<-->DOM so we'll be noisy there. |
@Prinzhorn You are indeed correct. I don't think there's any reason in particular not to allow it so we probably should change it then I would think.
@zpao But that's how the HTML5 spec defines |
Thanks guys! |
what is the state of this? |
No update. |
Allow numbers after `data-` in custom attributes fixes #2329
If the data attribute is formatted as
data-{number}-*
, then it won't be rendered into the HTML.Example:
http://jsfiddle.net/1etmp5fn/
Notice that
data-100-bucks
does not show up in the rendered result, whiledata-bucks-100
does.The text was updated successfully, but these errors were encountered: