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

RE: Surface JavaScript APIs for selector match changes

From: François REMY <francois.remy.dev@outlook.com>
Date: Tue, 15 Apr 2014 14:11:14 +0200
Message-ID: <DUB404-EAS172B4D3F9A54B4ECE00C183A5500@phx.gbl>
To: "'Tab Atkins Jr.'" <jackalmage@gmail.com>, "'Elliott Sprehn'" <esprehn@gmail.com>
CC: "'Joshua Peek'" <josh@joshpeek.com>, "'www-style list'" <www-style@w3.org>
± var sel = new Selector(".foo", document)
± sel.onchange  = function(event) { } instead.
± 
± ~TJ

FWIW, I like the idea of having a Selector object. Then we can start imagining other useful functions like helpers to compare the relative priority of two selectors, or whether a selector depends on features X or Y.

________________
Just because the conversation is there, I wanted to mention I made a prollyfill for Selectors Observers in the past, that works in that way:

    querySelectorLive("h2~p", {
        onadded: function(e) {
            console.log("h2~p added:");
            console.log(e.textContent);
        },
        onremoved: function(e) {
            console.log("h2~p removed:");
            console.log(e.textContent);
        }
    });

    https://github.com/FremyCompany/querySelectorLive/

The polyfill is sufficiently good (performance-wise) to be used on real websites while we wait for a standard approach. 

Regarding the idea of sending an array of elements being removed/added, I believe it would be more efficient because much less functions calls need to be done (for loops are cheap), but at the same time it makes the code a bit less elegant, I think. 
Received on Tuesday, 15 April 2014 12:11:44 UTC

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