± 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