-
Notifications
You must be signed in to change notification settings - Fork 43
Thet/4321 inject scroll #1269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thet/4321 inject scroll #1269
Changes from all commits
5de555b
f08b83f
ab78058
ba8ee80
380187b
5063f50
446cf06
c20c58a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -37,36 +37,61 @@ const document_ready = (fn) => { | |||||
| /** | ||||||
| * Return an array of DOM nodes. | ||||||
| * | ||||||
| * @param {Node|NodeList|jQuery} nodes - The DOM node to start the search from. | ||||||
| * @param {Node|NodeList|jQuery} nodes - The object which should be returned as array. | ||||||
| * | ||||||
| * @returns {Array} - An array of DOM nodes. | ||||||
| */ | ||||||
| const toNodeArray = (nodes) => { | ||||||
| if (nodes.jquery || nodes instanceof NodeList) { | ||||||
| // jQuery or document.querySelectorAll | ||||||
| const to_node_array = (nodes) => { | ||||||
| if (nodes?.jquery || nodes instanceof NodeList) { | ||||||
| nodes = [...nodes]; | ||||||
| } else if (nodes instanceof Array === false) { | ||||||
| nodes = [nodes]; | ||||||
| } | ||||||
| // Filter for DOM nodes only. | ||||||
| nodes = nodes.filter((node) => node instanceof Node); | ||||||
| return nodes; | ||||||
| }; | ||||||
|
|
||||||
| /** | ||||||
| * Return an array of DOM elements. | ||||||
| * | ||||||
| * @param {Node|NodeList|jQuery} nodes - The object which should be returned as array. | ||||||
|
||||||
| * @param {Node|NodeList|jQuery} nodes - The object which should be returned as array. | |
| * @param {Element|NodeList|jQuery} nodes - The object which should be returned as array. |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When selector is undefined or null and there are root elements, calling root.matches(selector) on line 85 will throw a TypeError. Consider adding a guard check: if (!selector) { return []; } at the beginning of the function to handle this edge case gracefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
nodesisundefinedornull, the conditionnodes instanceof Array === falseevaluates totrue, which wraps the falsy value in an array[undefined]or[null]. While the filter on line 51 removes these values, it's cleaner and more explicit to handle falsy values upfront. Consider adding a guard:if (!nodes) { return []; }at the beginning of the function.