select-animation 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/select-animation.js +37 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "select-animation",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "High-performance JavaScript animation engine for organic & fluid motion",
5
5
  "main": "select-animation.js",
6
6
  "scripts": {
@@ -101,36 +101,46 @@
101
101
  // Usage: select('.class', '#id')
102
102
  // -----------------------------
103
103
  // --- Enhanced DOM Selection Utility with Explicit Error Reporting ---
104
- const selectDom = function (selector) {
105
- // 1. Check if the input is a DOM element directly
106
- if (isElement(selector)) return [selector];
107
-
108
- // 2. Handle string selectors (e.g., ".class", "#id")
109
- if (typeof selector === "string") {
110
- const nodes = document.querySelectorAll(selector);
111
- if (nodes.length === 0) {
112
- // Warning if the selector is valid string but matches nothing
113
- console.warn(`Select-Animation: No elements found matching the selector "${selector}".`);
114
- }
115
- return Array.from(nodes);
116
- }
117
-
118
- // 3. Handle arrays or collections
119
- if (Array.isArray(selector) || (selector && typeof selector.length === "number")) {
120
- return Array.from(selector).filter(isElement);
104
+ // --- Enhanced DOM Selection Utility (Supports Multiple Arguments) ---
105
+ const selectDom = function (...selectors) {
106
+ const allElements = [];
107
+
108
+ // If no arguments were passed at all
109
+ if (selectors.length === 0) {
110
+ console.warn("Select-Animation: selectDom() was called without any arguments.");
111
+ return [];
121
112
  }
122
113
 
123
- // 4. CRITICAL: Handle invalid types (like numbers, null, undefined)
124
- if (selector !== undefined && selector !== null) {
125
- // Throwing a console error to stop the developer and force a fix
126
- console.error(
127
- `Select-Animation ERROR: Invalid input passed to selectDom().\n` +
128
- `Expected: String (selector), HTMLElement, or Array.\n` +
129
- `Received: ${typeof selector} (${selector})`
130
- );
131
- }
114
+ selectors.forEach((selector) => {
115
+ // 1. If the argument is already a DOM element
116
+ if (isElement(selector)) {
117
+ allElements.push(selector);
118
+ }
119
+ // 2. If the argument is a string (Selector)
120
+ else if (typeof selector === "string") {
121
+ const nodes = document.querySelectorAll(selector);
122
+ if (nodes.length === 0) {
123
+ console.warn(`Select-Animation: No elements found for selector "${selector}".`);
124
+ } else {
125
+ // Spread the NodeList into our results array
126
+ allElements.push(...Array.from(nodes));
127
+ }
128
+ }
129
+ // 3. If the argument is an array or collection
130
+ else if (Array.isArray(selector) || (selector && typeof selector.length === "number")) {
131
+ const filtered = Array.from(selector).filter(isElement);
132
+ allElements.push(...filtered);
133
+ }
134
+ // 4. INVALID INPUT: Alert the developer if they passed a number/null/etc.
135
+ else if (selector !== undefined && selector !== null) {
136
+ console.error(
137
+ `Select-Animation ERROR: Invalid selector type "${typeof selector}". ` +
138
+ `Expected String, Element, or Array, but received:`, selector
139
+ );
140
+ }
141
+ });
132
142
 
133
- return [];
143
+ return allElements;
134
144
  };
135
145
 
136
146
  // -----------------------------