Re: Making all elements and attributes that contain hyphens valid

Michael[tm] Smith, Wed, 16 Oct 2013 17:16:25 +0900:

> Well, after going back and actually reading the spec, I see I pretty much
> was wrong about what the spec says. The spec says this:
> 
> "JavaScript libraries may use the custom data attributes, as they are
> considered to be part of the page on which they are used. 

The spec contradicts itself. First: “private to the page or 
application”.[1] Thus, not libraries: “These attributes are not 
intended for use by software that is independent of the site that uses 
the attributes”.[1]

> For example, in the case of the Google Plus button markup, I see from
> reading their documentation[*] that there are a discrete set of values
> ("none", "bubble", and "inline") that the data-annotation attribute is
> expected to have, and a specific datatype (integer) that the data-width
> attribute is expected to be.
> 
> [*] https://developers.google.com/+/web/+1button/#plusone-tag-attributes


The specification of data-* talks of “custom data private to the page 
or application”.[1] I guess G+ can be seen as an application? It is 
*not*, quote: [1] ”generic software” (unlike e.g. JQuery.) Does G+ fall 
under the category of, quote [1] “software that is independent of the 
site that uses the attributes” ?

In the end, it becomes a tad difficult to discern between private and 
not-private use. The spec ought to give a broader definition of data-* 
so that one could spend less time on the question of whether it the 
usage i private or not.

> What I mean is, per the HTML spec, there are no invalid values for data-*
> attributes, any more than there are invalid values for the class attribute.

The definition of 'punch a whole in the spec'?

> I'd argue that in order to do the right thing for authors, we should keep
> it that way, and not have libraries and services like Google Plus relying
> on content to use data-* values with particular datatypes.

Then I think that the definition [1] of data-* should be updated. 
Currently, (and ignoring the contradiction that I pointed out above), 
its definition *prohibits* data-* from being used in 'generic 
software', such as libraries. So, in theory, the validator could, 
currently, do a negative validation - it could check that it is *not* 
used for generic software …

For instance, when it comes to the class attribute, then there is no 
prohibition that generic software should not rely on particular classes 
…?! And I really beliwve that data-* was introduced as solution to the 
problem of

    <div customFoo="bar">

which up until data-* had to, unconveniently, be solved via class (if 
validity was
important to you):

    <div class="foo=bar">

(For instance, Peter-Paul Koch, in his JavaScript book - issued before
data-* was introduced, includes a discussion of whether to use @class
or, the much simpler solution, a custom attribute. (As I remember, his 
example represented a data/info - it was not  a custom class).

[1] 
http://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes


[*] Btw the spec speak of 'they - the libraries' or 'they - the custom 
attributes'?)
-- 
leif halvard silli

Received on Wednesday, 16 October 2013 09:23:59 UTC