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

On Thu, Sep 24, 2009 at 12:02 AM, Mike Wilson <> 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(".infotip")) { /*...*/ }

could probably be made more efficient as:-

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

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)


Received on Thursday, 24 September 2009 08:30:59 UTC