W3C home > Mailing lists > Public > www-style@w3.org > April 2014

Re: Surface JavaScript APIs for selector match changes

From: Elliott Sprehn <esprehn@gmail.com>
Date: Wed, 9 Apr 2014 17:36:06 -0700
Message-ID: <CAPJYB1gDsLK5Oppjges-uTenQWHOuZy+GEAg=8sTy4A7iVXTTA@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Joshua Peek <josh@joshpeek.com>, www-style list <www-style@w3.org>
On Tue, Apr 8, 2014 at 5:51 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:

> ...
>
> > Although, I think I would find a more MutationObserver like API more
> > useful. Since it could pick up new elements added to the tree that
> > match the selector.
> >
> >     var observer = new SelectorObserver(function(record) {
> >       console.log(record.target, 'now matches', record.selector);
> >     });
> >     observer.observe(document, {selector: '.foo'});
>
> I've been thinking we should add a Selector interface anyway.  What
> about an API like:
>
> var sel = new Selector(".foo", document)
> sel.watch(function(record){...})
>

Please don't invent new event like things. That should be sel.onchange =
function(event) { } instead.

- E
Received on Thursday, 10 April 2014 00:37:13 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:39 UTC