[whatwg] Thoughts on HTML 5
Giovanni Campagna
scampa.giovanni at gmail.com
Tue Dec 16 05:14:16 PST 2008
Maybe so-called "invalid" HTML attributes are not the only solution, but in
my opinion it is a simple way to embed metadata within any element.
Imagine that such markup is then passed to a web application through XHR. In
that case scripts aren't parsed and executed. In this case you have three
ways to attach a behaviour:
2) on-event standard attributes (but they not performant since they're
parsed every time the event fires and the cannot include chars like > or ",
they need to be escaped)
3) assigning a "class" and some metadata using "data-", then
getElementsByClassName and addEventListener
The same with CSS: you can use "style" for each element or "data-"
attributes queried by attr()
For what concerns browser support, these attributes are at all part of the
DOM tree, so I can pass their names to getAttribute and setAttribute, but
they don't get any special interface.
It's the same in the XML serialization with different application-specific
namespaces: they use only DOMAttr interface defined in DOM3Core and they're
not part of any infoset (not part of ID list or NAME list)
Personally I prefer the latter (XML) solution, but there are context where
using XML serialization is not possibile (for example in user generated
content) so there is a definite need for a SGML way to add custom attributes
without conflicting with standards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20081216/22a589be/attachment-0001.htm>
More information about the whatwg
mailing list