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

Re: [selectors-api] Summary of Feature Requests for v2

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Thu, 24 Sep 2009 01:30:17 -0700
Message-ID: <c9e12660909240130v55108f14q1da138f5fb354eb4@mail.gmail.com>
To: Mike Wilson <mikewse@hotmail.com>
Cc: Lachlan Hunt <lachlan.hunt@lachy.id.au>, public-webapps <public-webapps@w3.org>
On Thu, Sep 24, 2009 at 12:02 AM, Mike Wilson <mikewse@hotmail.com> wrote:
> Yes, the base for event delegation is certainly something
> like that. I just wanted to make clear that the main reason
> for adding this functionality (IMO) is event delegation.
> I'll let event delegation library creators chime in on the
> details on what is needed for making really efficient
> behavioural/delegation implementations, and judge the merits
> of various optimizations. There has f ex already been mention
> of caching "parsed" selectors.
>

The benefit to that is that the selector text is parsed once, so
something like:-

document.onmouseover = function(ev) {
  if(ev.target.matchesSelector(".infotip")) { /*...*/ }
};

could probably be made more efficient as:-

var selector = QuerySelector.create(".infotip");
document.onmouseover = function(ev) {
  if(selector.matches(ev.target)) { /*...*/ }
};

The type of context where a QuerySelector object would be useful are
described above. That could be abstracted to a factory pattern that
uses selector to match nodes in a delegated event and lazily construct
a wrapper.

QuerySelector could be extended to have properties:
  readonly attribute boolean valid
  StaticNodeList match(in HTMLElement contextNode)

Garrett
Received on Thursday, 24 September 2009 08:30:59 GMT

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