- From: François REMY <francois.remy.dev@outlook.com>
- Date: Tue, 15 Apr 2014 14:11:14 +0200
- 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