W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2012

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

From: Rick Waldron <waldron.rick@gmail.com>
Date: Tue, 21 Aug 2012 18:29:48 -0400
Message-ID: <CAHfnhfojXUcTMRqLeigD_M9ayMQk7FMn9V2rHZOw3xWx293Zsw@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Brian Kardell <bkardell@gmail.com>, public-webapps <public-webapps@w3.org>, Ojan Vafai <ojan@chromium.org>
Comments inline...

On Tue, Aug 21, 2012 at 6:17 PM, Tab Atkins Jr. <jackalmage@gmail.com>wrote:

> On Tue, Aug 21, 2012 at 3:15 PM, Brian Kardell <bkardell@gmail.com> wrote:
> > On Aug 21, 2012 5:40 PM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote:
> >> On Tue, Aug 21, 2012 at 2:28 PM, Ojan Vafai <ojan@chromium.org> wrote:
> >>> On a somewhat unrelated note, could we somehow also incorporate jquery
> >>> style
> >>> live event handlers here? See previous www-dom discussion about this: .
> >>> I
> >>> suppose we'd still just want listen/unlisten(selector, handler)
> methods,
> >>> but
> >>> they'd get applied at the same time as cascaded attributes. Although,
> we
> >>> might want to apply those on attribute changes as well.
> >>
> >> Using CAS to apply an "onfoo" attribute is nearly the same (use a
> >> string value to pass the function, obviously).  It'll only allow a
> >> single listener to be applied, though.
> >>
> >> If it's considered worthwhile, we can magic up this case a bit.  CAS
> >> properties don't accept functions normally (or rather, as I have it
> >> defined in the OP, it would just accept a FUNCTION token, which is
> >> just the function name and opening paren, but I should tighten up that
> >> definition).  We could have a magic function like listen(<string>)
> >> that, when used on an onfoo attribute (more generally, on a
> >> host-language-defined "event listener" attribute) does an
> >> addEventListener() call rather than a setAttribute() call.
> >
> > Can you give some pseudo code or something that is relatively close to
> what
> > you mean here?  I'm not entirely sure I follow.
>
> Sure!
>
> 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');";
> }
>

This is certainly interesting, but...

1. It's a string that will have to be eval'ed, right? In what scope? Does
this get wrapped in a function expression?
2. Using inline attributes that match up to node.onfoo will pave over each
other... if some other style sheet is introduced, by some third party
widget that happens to have

ul.special > li {
  onclick: "alert('busted')";
}

...Bummer?

3. Where did "evt" come from?


> 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');");
> }
>

How do we know where the body ends?


>
> ~TJ
>


Thanks in advance! :)

Rick
Received on Tuesday, 21 August 2012 22:30:36 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:54 GMT