Re: Making all elements and attributes that contain hyphens valid

Michael[tm] Smith writes:

> James Graham <james@hoppipolla.co.uk>, 2013-10-16 12:39 +0100:
> 
> > If you embed a library in your page, your page isn't independent of
> > that library and so the library doesn't count as "software that is
> > independent of the site that uses the attributes". That clause is
> > supposed to forbid using data-* for e.g. microformats where one
> > might write microformat-consuming software that is entirely
> > decoupled from the site the markup appears on.
> > 
> > Given this, I don't understand why you would want xxx-foo rather than
> > data-xxx-foo.
> 
> If you look at it from the perspective of authors using the attributes
> from your library, I think the question should be, why would authors
> want to use data-xxx-foo rather than xxx-foo.

It gives them the assurance that those attributes won't clash with
future additions to HTML, nor with any other applicable standard. They
can safely use them, knowing that no user agent is going to interpret
the attribute at all (so there's no risk of it interpreting it in an
unintended way).

The data-* namespace is safe for the site (including any libraries it
uses) to do whatever it wants with, in the way that arbitrary attributes
can't be.

(Or, if all attributes with hyphens in were deemed safe for authors to
use like this, that would prevent any future applicable spec from
defining any new attributes with hyphens in them: they may clash with
attributes authors or libraries are already using. That'd either be a
massive restriction on future applicable specs, preventing any of them
from using their own foo-* prefix on attributes.)

> Along with that, by providing authors with data-xxx-foo attributes to
> use instead of xxx-foo attributes, you're making things harder for
> authors to catch some kinds of authoring mistakes they might make. The
> only way they're like to be able to catch syntax/datatype errors with
> data-xxx-foo is by testing the code by running and hoping that it will
> fail in some obvious way if they have a syntax error in a data-xxx-foo
> value.

I don't see how that follows. In order for a validator to assist authors
using libraries, it needs to know specifically about each library and
what values are valid for its attributes. For each library that a
validator knows about, it could provide options for users to indicate
that the site is using, say, the Kapow library, and that the prefix in
use for that library's attributes is data-kapow-.

Then the validator can check the values, just as it could if the
attributes were called kapow-*.

> Because by using data-xxx-foo you're basically buying into a contract
> that says the attributes and their values should be ignored by any
> applications except the library that they're designed to be run with.

If an author is running a validator on her own site, and has configured
that validator to know that particular data-* attributes should obey
particular syntax, I think it could be claimed that that run of the
validator is effectively part of the author's site: the meaning of the
attributes is only known because the author has baked this into the
validator in an out-of-band way; the validator wouldn't be deriving any
meaning from them based purely on their names.

Or, if you think that that interpretation is too much of a stretch (you
wouldn't be comfortable that such a validator feature would be compliant
with HTML), then we could change HTML to make an explicit affordance for
the case of a validators looking at particular data-* elements when
instructed to do so by authors.

Cheers

Smylers
-- 
Stop drug companies hiding negative research results. Sign the AllTrials
petition to get all clinical research results published. Read more:
http://www.alltrials.net/blog/the-alltrials-campaign/

Received on Wednesday, 16 October 2013 13:10:45 UTC