Re: Surface JavaScript APIs for selector match changes

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