On Mon, 21 Oct 2013, Eric Seidel wrote:
>
> I see. This seems like something much better handled by
> custom-elements (once we get that):
>
> var HTMLTimeElement = document.register('time', {
> prototype: Object.create(HTMLElement.prototype, {
> datetime: {
> get: function() { return this.getAttribute('datetime'); }
> set: function(value) { return this.setAttribute('datetime'); }
> }
> });
>
> That's certainly *much* safe/simpler than adding any more C++ code to Blink. :)
There's four main purposes for <time>:
- helping authors who want to mark up times and have a reliable way to do
so, for internal purposes. Browsers don't need to do much for this; as
you say, the above would be sufficient.
- in the future, providing a place for hooking localisation of
time-related values, should CSS provide a way to do that. This is
currently academic since CSS doesn't provide this.
- a place for giving time-related values when doing stuff with microdata.
Browsers aren't really affected by this (there's some minor stuff
involved if you have the microdata DOM API, but that's all).
- integration with the table sorting model. This one requires significant
work to be implemented in the browser; the times have to be parsed,
their type has to be identified, etc.
Basically, whenever there's something related to encoding times in HTML,
the <time> element is what gets used. Except for sorting, this has very
little impact on HTML.
The sorting model hasn't received much review from browser vendors; I'm
curious to hear what y'all have to say about it. It was designed to take
care of a quite wide variety of needs, so there's quite a lot to it, but
it's described in quite a lot of detail, so it should be relatively
straight forward to implement. It's certainly something a lot of authors
have been asking for. The API it exposes to authors is really simple given
the amount of power it packs.
http://whatwg.org/html#table-sorting-model
(Note: There's an open question about how to handle cells with two types
of data that I haven't dealt with yet.)
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'