- From: Sylvain Galineau <sylvaing@microsoft.com>
- Date: Thu, 23 Feb 2012 17:38:26 +0000
- To: Brad Kemper <brad.kemper@gmail.com>, Tab Atkins Jr. <jackalmage@gmail.com>
- CC: David Hyatt <hyatt@apple.com>, Vincent Hardy <vhardy@adobe.com>, www-style list <www-style@w3.org>
[Brad Kemper:] > > > On Feb 23, 2012, at 8:44 AM, "Tab Atkins Jr." <jackalmage@gmail.com> > wrote: > > > On Mon, Feb 20, 2012 at 11:25 AM, Brad Kemper <brad.kemper@gmail.com> > wrote: > >> On Feb 20, 2012, at 9:51 AM, David Hyatt <hyatt@apple.com> wrote: > >> > >>> On Feb 17, 2012, at 6:39 PM, Sylvain Galineau wrote: > >>> > >>>>> sylvaing: without dom elements, you can't receive clicks, etc. > >>>>> > >>>>> That seems like a solvable problem that should be solved for all > generated pseudo-elements (like ::before and ::after too). Something like > >'getElementsByTagName("body")[0].pseudos.slot[0]'.addEventListener(click, > myfunction)'. > >>>> > >>>> That is the general concept, yes. Though such nodes are by > >>>> definition not in the DOM and using the same plumbing means > >>>> defining what bubbling and other things that assume a parent chain > look like. I haven't thought about it much yet but my working assumption > is that it could be trickier than it looks. > >>>> > >>> > >>> Rather than adding event handlers to the anonymous boxes, I think it > would be simpler if you just register event handlers with the nearest > enclosing explicit DOM element, and then have a field that allows you to > figure out which anonymous box was hit. > > >> > >> So... Something like this? > >> > >> getElementsByTagName("body")[0].addEventListener(click, myfunction, > >> pseudos.slot[0]) > >> > >> Or maybe I misunderstand you. Legacy browsers would ignore the extra > argument, wouldn't they? > > > > I believe he means a property on the event object exposing which > > pseudo on the event's target was hit. So if you just wanted to listen > > for clicks on a ::before, you'd write something like: > > > > el.onclick = function(e) { > > if( e.target.pseudo == "before" ) { > > ... > > } > > } > > Oh, OK. I like that. It is clean, and makes sense. It makes sense; I'm not sure having string-based switch-case branching is so clean if/when you'll deal with entire pages worth of auto-generated pseudos. So while I think it makes sense to have this capability (it'd be useful even today imo) I'm not sure it's enough though it's a fine place to start.
Received on Thursday, 23 February 2012 17:39:08 UTC