Element.dataset is nice, because when it is implemented by the browser
Your code can just use the browser version. And because it is in the
html standard more and more people would use it anyway, so in the end
we would have two idioms (Element.dataset['fooBar'] and
Element.get('data-foo-bar')) in the code doing exactly the same
thing, which is a mess and decreases readability.
just my two cents...
On Jun 28, 6:53 pm, Ryan Florence <[email protected]> wrote:
> jQuery's combination of element storage + data attributes is rather elegant.
>
> <div id=el data-foo=bar></div>
>
> $('#el').data('foo') //> 'bar';
>
> I've been thinking of implementing the same behavior in
> Element.prototype.retrieve, though get('data-foo') is completely adequate.
>
> These attributes are incredibly useful in client-side templating and
> declarative JavaScript architectures.
>
> As for the tangent on this thread ... If you're concerned about validating
> XHTML, I feel bad for you.
>
> On Jun 28, 2011, at 10:00 AM, Arieh Glazer wrote:
>
>
>
>
>
>
>
> > So what? What does valid mean? Does it break any browser - no. Does it
> > break the semantics of the page? no. Does it decrease your ability to use
> > the validator to identify syntax errors? maybe - but then again - why not
> > simply switch to h5? the browsers couldn't care less about your doctype (as
> > documented at several different resources)
>
> > On Tue, Jun 28, 2011 at 6:40 PM, Steve Onnis <[email protected]> wrote:
> > It might work but it is not valid XHTML pre HTML5
>
> > From: Arian Stolwijk [mailto:[email protected]]
> > Sent: Wednesday, 29 June 2011 12:50 AM
>
> > To: [email protected]
> > Subject: Re: [Moo] Re: Custom data attribute
>
> > this does even work in IE6.
>
> > On Tue, Jun 28, 2011 at 4:12 PM, Steve Onnis <[email protected]> wrote:
>
> > The comment was in reference to pre HTML5 as it was asked if mootools would
> > support custom attributes for non HTML5 browsers
>
> > -----Original Message-----
> > From: Tim Wienk [mailto:[email protected]]
> > Sent: Tuesday, 28 June 2011 11:14 PM
> > To: [email protected]
> > Subject: Re: [Moo] Re: Custom data attribute
>
> > On Tue, Jun 28, 2011 at 15:03, Steve Onnis <[email protected]> wrote:
> > > Keep in mind though that doing that sort of thing will invalidate your
> > > XHTML
> > > unless you generate your own dtd schema and implement that
>
> >http://dev.w3.org/html5/spec/elements.html#embedding-custom-non-visib...
>
> > --
> > Tim Wienk, Software Developer, MooTools Developer
> > E. [email protected] | W.http://tim.wienk.name
>
> > --
> > Arieh Glazer
> > אריה גלזר
> > 052-5348-561
> >http://www.arieh.co.il
> >http://www.link-wd.co.il