Created
June 30, 2024 11:36
-
-
Save theking2/79cea0ee7bc80e77c0a39d210dae6c89 to your computer and use it in GitHub Desktop.
Revisions
-
theking2 created this gist
Jun 30, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ /** * returns a static (not live) NodeList representing a list of the document's elements that match the specified group of selectors. * @param {string} selector * @param {Element} [document] base * @returns {(NodeList|Element|null)} */ const $ = (selector, base = document) => { let elements = base.querySelectorAll(selector); return (elements.length == 0) ? null : (elements.length == 1) ? elements[0] : elements; }