Re: Surface JavaScript APIs for selector match changes

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