Re: Proposal for "Cascading Attribute Sheets" - like CSS, but for attributes!

On Aug 21, 2012 6:49 PM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote:
>
> On Tue, Aug 21, 2012 at 3:44 PM, Brian Kardell <bkardell@gmail.com> wrote:
> > On Aug 21, 2012 6:18 PM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote:
> >> So, in my current proposal, you can just set an onfoo attribute:
> >>
> >> ul.special > li {
> >>   onclick: "alert('You clicked me!');
> >> evt.target.classlist.add('clicked');";
> >> }
> >>
> >> Here's a suggestion for a similar API that would invoke
> >> addEventListener instead of setAttribute:
> >>
> >> ul.special > li {
> >>   onclick: listen("alert('You clicked me!');
> >> evt.target.classlist.add('clicked');");
> >> }
> >
> > This feels a lot like netscape's old actionsheets proposal.  Doesn't it
> > create the same footgun I mentioned above though?  Would you be blocked
off
> > from accessing dom in those handlers? Or are the read only (you may
remember
> > you, borris and I discussed how that might work last year)  In other
words,
> > what is preventing you from writing...
> >
> > .foo .bar{
> >     onclick: listen(create a .bar and attach it as a child of
evt.target);
> > }
>
> Nothing prevents you from writing that.  That's not problematic at
> all, though.  When you click on a .bar, it creates a sibling .bar and
> gives it the same onclick.  I think you've confused yourself into
> thinking this is an infinite loop - it's not.
>
> Since you can't create a mutation observer with an attribute, I don't
> think you can infinite-loop yourself at all.  Even if you could, it's
> no more troublesome than the same possibility in pure JS.
>
> ~TJ

You are right, I was thinking that :)  I blame it on doing this all on my
cell phone.  Ok.  If you click on the inner foo, now both will fire unless
you pop the bubble, right?  That is probably fine.  Do you need the quotes
if you do it inside a type fn like listen?  Could we not parse around
that?

Received on Tuesday, 21 August 2012 22:55:28 UTC