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

Re: Surface JavaScript APIs for selector match changes

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 9 Apr 2014 17:43:45 -0700
Message-ID: <CAAWBYDC1RK66bx7MLRCnKt10fi+zGkdKaF3Zp1ymGp+daNLN3A@mail.gmail.com>
To: Elliott Sprehn <esprehn@gmail.com>
Cc: Joshua Peek <josh@joshpeek.com>, www-style list <www-style@w3.org>
On Wed, Apr 9, 2014 at 5:36 PM, Elliott Sprehn <esprehn@gmail.com> wrote:
> 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.

Yeah, I was leaning that way too.  I'm fine with that.

~TJ
Received on Thursday, 10 April 2014 00:44:32 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:21 UTC