|
|
|
|
|
by 1GZ0
617 days ago
|
|
I wrote my first jQuery lite selector clone a bit ago, any feedback would be appreciated, especially since I don't see the need to separate out querySelector & querySelectorAll ```
const $ = (param) => {
if (typeof param === "string" || param instanceof String) {
const elm = document.querySelectorAll(param);
return elm.length > 1 ? elm : document.querySelector(param);
} else {
return [param].length === 1 ? [param][0] : [param];
}
};
``` |
|