Re-Query Select All the Things!

Re-Query Select All the Things!

Remember last week when I spoke about how to use querySelect() and querySelectAll() and how it could all be done in one command I called qs()()? Remember reading the part about how after some research, I’ve had though about redesigning the function?

Hi JR - an awesome function - takes something I’ve been doing to a whole new level. Thank you!

Small issue - you have a typo in your updated function:

var qs = parent => query => {let q; return (typeof(parent) === “string”) ? qs(qs()(parent))(query) : (q = (parent||document).querySelector(query)).length > 1 ? q : (q[0]||null);};

You forgot the word “All” after .querySelector…

Should be:
var qs = parent => query => {let q; return (typeof(parent) === “string”) ? qs(qs()(parent))(query) : (q = (parent||document).querySelectorAll(query)).length > 1 ? q : (q[0]||null);};

Thanks again - I’ll be grabbing this and utilsing it. Does it still work if you decide to use “use strict”? It currently seems to - but is there some issue if one does that?

marty_m