Why not using HTML5 data-* attributes
See original GitHub issueHi, is there a good reason why you don’t go with the data-*
attributes and invent your own standard with v-*
?
From https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes:
In addition, search crawlers do not index data attributes’ values.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:5
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Using data attributes - Learn web development | MDN
HTML is designed with extensibility in mind for data that should be associated with a particular element but need not have any defined...
Read more >How You Can Use HTML5 Custom Data Attributes and Why
Gajendar Singh walks you through HTML5 custom data attributes, why they're useful, how to style them with CSS and manipulate them with ......
Read more >Don't use data attributes to find HTML elements with JS - intuio
Custom data attributes are intended to store custom data private to the page or application, for which there are no more appropriate attributes...
Read more >Is there any problem with using HTML5's "data-*" attributes for ...
I want to associate some custom data with some HTML nodes. I was going to use the new HTML5 style 'data-*' attributes. e.g.:...
Read more >HTML5 Data Attributes - Medium
data-* attributes allow us to store extra information on standard, semantic HTML elements without other hacks such as non-standard ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Note the difference between valid HTML syntax vs fully-valid HTML. The former means it adheres to the syntax constraints laid out in the spec, and only the syntax; the latter entails following the spec to every extreme detail, e.g. if an element doesn’t have a certain attribute then you cannot use it on that element.
At the syntax level attribute names are defined as follows:
So all Vue templates are valid HTML at the syntax level. We have practical reasons to do that because it enables any spec-compliant HTML parser to be able to parse Vue templates - this makes it possible to reuse excellent HTML-based tools already out there in all aspects of tooling. However, it is my opinion that striving for fully-valid HTML in a templating syntax is completely pointless, because the template is not what eventually gets rendered in the browser. The template’s job is to convey the connection between your JavaScript model and the final desired output (which should be, and will be fully-valid HTML). Making your templates fully valid HTML has zero practical benefits except for maybe getting rid of the warnings from your overly-rigorous IDE.
Maybe it would be a good idea to document this design-decision somewhere inside the vue-documentation. As the attributes are not “XML-attribute”-compatible (because they are containing the colon sign U+003A) this must have been decided sometime in the past.
Any relation to some specs for HTML5 would be nice, there seems a lot of confusion about this whole “data-” thing. Don’t get me wrong, I used to understand HTML differently, but it seems to “just work” inside the browsers … but fails for syntax-checker even like the w3c-markup checker. I tried some dummy website of mine, how the syntax checker sees some
v-on:click
and attributes, and it fails with errors likeAttribute v-if not allowed on element div at this point.
. When there is some evaluation about used web-frameworks, and the customer requires the website to be syntax-checker-compliant, then Vue can’t be used.Could we (developers) please have some references where the design-decision are coming from? (and yes, it feels a bit odd to “discuss” this on some closed issue …)