dom-primitive-bindings 1.0.0 → 1.4.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 (55) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +163 -126
  3. package/package.json +27 -36
  4. package/src/index.js +3 -3
  5. package/src/{v1 → v2}/dispatch/executeBinding.js +21 -21
  6. package/src/{v1 → v2}/dispatch/getClientData.js +8 -8
  7. package/src/{v1 → v2}/dispatch/getStartInput.js +10 -10
  8. package/src/{v1 → v2}/dispatch/index.js +15 -15
  9. package/src/{v1 → v2}/guards/bindings/index.js +11 -11
  10. package/src/{v1 → v2}/guards/bindings/validateArray.js +10 -10
  11. package/src/{v1 → v2}/guards/container/index.js +13 -13
  12. package/src/{v1 → v2}/guards/container/resolveElement.js +14 -14
  13. package/src/{v1 → v2}/guards/index.js +15 -15
  14. package/src/{v1 → v2}/index.js +22 -22
  15. package/src/{v1 → v2}/listeners/attachListener.js +10 -10
  16. package/src/{v1 → v2}/listeners/index.js +12 -12
  17. package/src/{v1 → v2}/prepare/groupBindings.js +14 -14
  18. package/src/{v1 → v2}/prepare/index.js +8 -8
  19. package/src/{v1 → v2}/register/index.js +18 -17
  20. package/src/{v1 → v2}/register/meta.js +6 -7
  21. package/src/v3/dispatch/executeBinding.js +21 -0
  22. package/src/v3/dispatch/getClientData.js +8 -0
  23. package/src/v3/dispatch/getStartInput.js +10 -0
  24. package/src/v3/dispatch/index.js +15 -0
  25. package/src/v3/guards/bindings/index.js +11 -0
  26. package/src/v3/guards/bindings/validateArray.js +10 -0
  27. package/src/v3/guards/container/index.js +13 -0
  28. package/src/v3/guards/container/resolveElement.js +14 -0
  29. package/src/v3/guards/index.js +15 -0
  30. package/src/v3/index.js +22 -0
  31. package/src/v3/listeners/attachListener.js +10 -0
  32. package/src/v3/listeners/index.js +12 -0
  33. package/src/v3/prepare/groupBindings.js +14 -0
  34. package/src/v3/prepare/index.js +8 -0
  35. package/src/v3/register/index.js +18 -0
  36. package/src/v3/register/meta.js +6 -0
  37. package/src/v4/dispatch/executeBinding.js +21 -0
  38. package/src/v4/dispatch/getClientData.js +8 -0
  39. package/src/v4/dispatch/getStartInput.js +10 -0
  40. package/src/v4/dispatch/index.js +15 -0
  41. package/src/v4/guards/bindings/index.js +11 -0
  42. package/src/v4/guards/bindings/validateArray.js +10 -0
  43. package/src/v4/guards/container/index.js +13 -0
  44. package/src/v4/guards/container/resolveElement.js +14 -0
  45. package/src/v4/guards/index.js +15 -0
  46. package/src/v4/index.js +22 -0
  47. package/src/v4/listeners/attachListener.js +10 -0
  48. package/src/v4/listeners/index.js +12 -0
  49. package/src/v4/prepare/groupBindings.js +14 -0
  50. package/src/v4/prepare/index.js +8 -0
  51. package/src/v4/register/index.js +18 -0
  52. package/src/v4/register/meta.js +6 -0
  53. package/docs/dist/min.js +0 -63
  54. package/docs/dist/v1/min.js +0 -63
  55. package/docs/index.html +0 -185
package/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 KeshavSoft
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KeshavSoft
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md CHANGED
@@ -1,126 +1,163 @@
1
- # DOM Primitive Bindings
2
-
3
- > Modern, lightweight, delegated event engine for browser DOMs. Attach exactly one listener per event type to any container; let bubbling handle matching, runners, and extraction with zero re-binding overhead.
4
-
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
- [![Tests](https://img.shields.io/badge/tests-passing-brightgreen.svg)]()
7
- [![Single Source of Truth](https://img.shields.io/badge/Version-v1-blue.svg)]()
8
-
9
- ---
10
-
11
- ## 🎯 The Core Concept
12
-
13
- Traditional client-side code attaches listeners to every button, link, and input. When tables are refreshed, cards are added, or modals render dynamic markup, those listeners break or leak memory unless manually re-attached.
14
-
15
- **DOM Primitive Bindings** inverts the architecture:
16
- - Attach **one listener** per event type to the parent container (`table`, `form`, `card-grid`).
17
- - As events bubble up, `closest(selector)` identifies target elements.
18
- - The associated `runner` executes and forwards data cleanly to `onExtract`.
19
- - Dynamically created DOM elements are supported immediately with **zero re-binding**.
20
-
21
- ---
22
-
23
- ## 🏗️ Staged Architecture (`src/v1/`)
24
-
25
- The repository strictly enforces a staged pipeline where every directory contains an `index.js` and all files export a single function as `default`:
26
-
27
- ```text
28
- src/
29
- └── v1/
30
- ├── guards/ # Validates container and bindings array
31
- │ ├── container/ # Validates and resolves 1st input (container / ID)
32
- │ ├── bindings/ # Validates 2nd input (bindings array)
33
- │ └── index.js
34
- ├── prepare/ # Groups bindings by event type into Map
35
- │ ├── groupBindings.js
36
- │ └── index.js
37
- ├── listeners/ # Attaches single listener per event type to container
38
- │ ├── attachListener.js
39
- │ └── index.js
40
- ├── dispatch/ # Handles event bubbling, runner execution & extraction
41
- │ ├── getStartInput.js
42
- │ ├── getClientData.js
43
- │ ├── executeBinding.js
44
- │ └── index.js
45
- ├── register/ # Exposes module onto window.ks.domPrimitiveBindings
46
- │ ├── meta.js
47
- │ └── index.js
48
- └── index.js # Orchestrator exporting bindEvents
49
- ```
50
-
51
- ### Key Design Disciplines
52
- 1. **Zero Comments:** The folder hierarchy and descriptive file names convey the full narrative without inline code comments.
53
- 2. **Folder Discipline:** Every folder contains an `index.js` public gateway.
54
- 3. **Single Function Default Export:** No default export objects; every file exports a single function.
55
-
56
- ---
57
-
58
- ## 🚀 Interactive Browser Samples (`samples/v1/`)
59
-
60
- Start the Vite development server to view and interact with real browser DOM events:
61
-
62
- ```bash
63
- npm install
64
- npm run dev
65
- ```
66
-
67
- Open in Chrome or Edge:
68
- - **`samples/v1/tableWithSearch/`** — Delegated table row clicks and live Enter-key search input.
69
- - **`samples/v1/cardGrid/`** — Dynamic card insertion into DOM with instant delegated action buttons.
70
- - **`samples/v1/formEvents/`** — Live form field inputs, dropdown selection changes, and submit/clear buttons.
71
-
72
- ---
73
-
74
- ## 📦 Usage
75
-
76
- ### Browser (ES Module / Script)
77
-
78
- ```html
79
- <script type="module" src="./docs/dist/v1/min.js"></script>
80
- <script type="module">
81
- const bindings = [
82
- {
83
- event: "click",
84
- selector: ".btn-cart",
85
- runner: (target) => ({ productId: target.dataset.id }),
86
- onExtract: (data) => console.log("Added to cart:", data)
87
- }
88
- ];
89
-
90
- window.ks.domPrimitiveBindings.bindEvents("products-container", bindings);
91
- </script>
92
- ```
93
-
94
- ### Module Import
95
-
96
- ```javascript
97
- import { bindEvents } from "dom-primitive-bindings";
98
-
99
- bindEvents(containerElement, [
100
- {
101
- event: "click",
102
- selector: ".action-btn",
103
- runner: (btn) => btn.dataset.action,
104
- onExtract: (action) => console.log("Action:", action)
105
- }
106
- ]);
107
- ```
108
-
109
- ---
110
-
111
- ## 🧪 Testing & Build
112
-
113
- ```bash
114
- # Run unit tests
115
- npm test
116
-
117
- # Build production bundle to docs/dist/v1/min.js
118
- npm run build
119
- ```
120
-
121
- ---
122
-
123
- ## 📄 License
124
-
125
- MIT © KeshavSoft
126
-
1
+ # DOM Primitive Bindings
2
+
3
+ > Modern, lightweight, single-listener delegated event engine for browser DOMs. Driven by declarative `bindings.json` configurations with zero DOM manipulation and zero schema extraction.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/dom-primitive-bindings.svg?style=flat-square)](https://www.npmjs.com/package/dom-primitive-bindings)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
7
+ [![Single Source of Truth](https://img.shields.io/badge/Version-v3-blue.svg?style=flat-square)]()
8
+ [![Documentation](https://img.shields.io/badge/Docs-Architecture%20%26%20Stories-green.svg?style=flat-square)](./docs/index.html)
9
+
10
+ ---
11
+
12
+ ## 📖 The 4-Part Event Delegation Story
13
+
14
+ Explore the interactive interactive story chapters in [`docs/stories/`](./docs/index.html):
15
+
16
+ 1. **[Chapter 1: The Everyday Habit & The Listener Trap](./docs/stories/01-the-listener-trap.html)**
17
+ Why attaching listeners to individual elements causes memory leaks, double-trigger cascades, and dead-zones on dynamic elements.
18
+ 2. **[Chapter 2: The Delegation Epiphany](./docs/stories/02-the-delegation-epiphany.html)**
19
+ Harnessing browser event bubbling: 1 container listener catching bubbling events forever.
20
+ 3. **[Chapter 3: The Staged Pipeline Architecture](./docs/stories/03-the-staged-pipeline.html)**
21
+ Inside the decoupled 4-stage pipeline: `guards` $\to$ `prepare` $\to$ `listeners` $\to$ `dispatch`.
22
+ 4. **[Chapter 4: The Joy of Declarative JSON](./docs/stories/04-declarative-json-bindings.html)**
23
+ Moving from imperative JavaScript arrays to clean, serializable `bindings.json` specifications with a live interactive demo.
24
+
25
+ ---
26
+
27
+ ## 🎯 The Philosophy: The Wiring Layer
28
+
29
+ A common mistake in UI architecture is conflating **event wiring** with **DOM manipulation** or **data extraction**:
30
+
31
+ - **`dom-primitive-bindings` (This Repository):**
32
+ Pure **Wiring Layer**. Attaches one container listener per event type, matches bubbling targets via `closest(selector)`, and delivers `{ event, targetElement }`. It does **not** manipulate DOM elements and does **not** extract table schemas into objects.
33
+ - **`dom-primitive-engine` (Sibling Repository):**
34
+ Pure **Extraction Layer**. Receives the matched target element and executes declarative instruction pipelines (e.g. `closest("tr")`, `querySelectorAll("td")`, column mapping) to produce clean JSON.
35
+
36
+ ```text
37
+ [ User Action in Browser ]
38
+ │
39
+ ▼
40
+ ┌───────────────────────────────┐
41
+ │ dom-primitive-bindings │ ◄── Wiring Layer: Catches event & matches target
42
+ │ (guards → prepare → dispatch)│
43
+ └──────────────┬────────────────┘
44
+ │ delivers { event, targetElement }
45
+ ▼
46
+ ┌───────────────────────────────┐
47
+ │ Consumer / App Logic │ ◄── Extraction (dom-primitive-engine) or App Handler
48
+ └───────────────────────────────┘
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 🏗️ Staged Architecture (`src/v3/`)
54
+
55
+ The engine enforces a staged pipeline where every directory contains an `index.js` and all files export a single function as `default`:
56
+
57
+ ```text
58
+ src/v3/
59
+ ├── guards/ # Validates container & bindings array
60
+ │ ├── container/ # Resolves 1st input (container ID or DOM element)
61
+ │ ├── bindings/ # Filters and validates 2nd input (bindings array)
62
+ │ └── index.js
63
+ ├── prepare/ # Groups bindings by event type into Map
64
+ │ ├── groupBindings.js
65
+ │ └── index.js
66
+ ├── listeners/ # Attaches single container listener per event type
67
+ │ ├── attachListener.js
68
+ │ └── index.js
69
+ ├── dispatch/ # Handles event bubbling, target matching & execution
70
+ │ ├── getStartInput.js
71
+ │ ├── getClientData.js
72
+ │ ├── executeBinding.js
73
+ │ └── index.js
74
+ ├── register/ # Exposes module onto window.ks.domPrimitiveBindings
75
+ │ ├── meta.js
76
+ │ └── index.js
77
+ └── index.js # Orchestrator
78
+ ```
79
+
80
+ ### Key Design Disciplines
81
+ 1. **Zero Comments:** The folder hierarchy and descriptive file names convey the full narrative without inline code comments.
82
+ 2. **Folder Discipline:** Every folder contains an `index.js` public gateway.
83
+ 3. **Single Function Default Export:** No default export objects; every file exports a single function.
84
+ 4. **Declarative JSON:** Bindings are defined in serializable `bindings.json` files.
85
+
86
+ ---
87
+
88
+ ## 🚀 Interactive Browser Samples (`samples/v3/`)
89
+
90
+ Start the Vite development server to view and interact with real browser DOM events:
91
+
92
+ ```bash
93
+ npm install
94
+ npm run dev
95
+ ```
96
+
97
+ Open in Chrome or Edge:
98
+ - **`samples/v3/tableWithSearch/`** — Declarative table row clicks and live Enter-key search input loaded from `bindings.json`.
99
+ - **`samples/v3/cardGrid/`** — Declarative card button and card body click bindings loaded from `bindings.json`.
100
+ - **`samples/v3/formEvents/`** — Declarative input, change, and button click bindings loaded from `bindings.json`.
101
+
102
+ ---
103
+
104
+ ## 📦 Usage
105
+
106
+ ### 1. Declare `bindings.json`
107
+
108
+ ```json
109
+ [
110
+ {
111
+ "event": "click",
112
+ "selector": ".btn-action"
113
+ },
114
+ {
115
+ "event": "keydown",
116
+ "selector": "input[type='search']"
117
+ }
118
+ ]
119
+ ```
120
+
121
+ ### 2. Run with `bindEvents`
122
+
123
+ ```javascript
124
+ import bindings from "./bindings.json" with { type: "json" };
125
+ import { bindEvents } from "dom-primitive-bindings";
126
+
127
+ bindEvents("container-id", bindings);
128
+ ```
129
+
130
+ Or via global browser script:
131
+
132
+ ```html
133
+ <script type="module" src="./docs/dist/v3/min.js"></script>
134
+ <script type="module">
135
+ import bindings from "./bindings.json" with { type: "json" };
136
+ window.ks.domPrimitiveBindings.bindEvents("container-id", bindings);
137
+ </script>
138
+ ```
139
+
140
+ ---
141
+
142
+ ## 📚 Technical Specifications
143
+
144
+ - **[Architecture & Design Story](./docs/architecture.md)**: Deep dive into the 4 internal stages and data flow.
145
+ - **[Binding Specification Schema](./docs/binding-spec.md)**: Complete property reference for `bindings.json`.
146
+
147
+ ---
148
+
149
+ ## 🧪 Testing & Build
150
+
151
+ ```bash
152
+ # Run unit tests
153
+ npm test
154
+
155
+ # Build production bundle to docs/dist/v3/min.js
156
+ npm run build
157
+ ```
158
+
159
+ ---
160
+
161
+ ## 📄 License
162
+
163
+ MIT © KeshavSoft
package/package.json CHANGED
@@ -1,36 +1,27 @@
1
- {
2
- "name": "dom-primitive-bindings",
3
- "version": "1.0.0",
4
- "description": "Declarative, instruction-driven DOM delegated event bindings",
5
- "type": "module",
6
- "license": "MIT",
7
- "author": "KeshavSoft",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/keshavsoft/dom-primitive-bindings.git"
11
- },
12
- "bugs": {
13
- "url": "https://github.com/keshavsoft/dom-primitive-bindings/issues"
14
- },
15
- "homepage": "https://github.com/keshavsoft/dom-primitive-bindings#readme",
16
- "main": "./src/index.js",
17
- "exports": {
18
- ".": "./src/index.js"
19
- },
20
- "files": [
21
- "src/index.js",
22
- "src/v1",
23
- "docs",
24
- "README.md",
25
- "LICENSE"
26
- ],
27
- "scripts": {
28
- "dev": "vite",
29
- "build": "vite build",
30
- "preview": "vite preview",
31
- "test": "node --test"
32
- },
33
- "devDependencies": {
34
- "vite": "^6.4.1"
35
- }
36
- }
1
+ {
2
+ "name": "dom-primitive-bindings",
3
+ "version": "1.4.1",
4
+ "description": "Declarative, instruction-driven DOM delegated event bindings",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "KeshavSoft",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/keshavsoft/dom-primitive-bindings.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/keshavsoft/dom-primitive-bindings/issues"
14
+ },
15
+ "homepage": "https://github.com/keshavsoft/dom-primitive-bindings#readme",
16
+ "main": "./src/index.js",
17
+ "exports": {
18
+ ".": "./src/index.js"
19
+ },
20
+ "files": [
21
+ "src",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {},
26
+ "devDependencies": {}
27
+ }
package/src/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./v1/index.js";
2
- export { default } from "./v1/index.js";
3
-
1
+ export * from "./v4/index.js";
2
+
3
+ export { default } from "./v4/index.js";
@@ -1,21 +1,21 @@
1
- import getStartInput from "./getStartInput.js";
2
- import getClientData from "./getClientData.js";
3
-
4
- const executeBinding = ({ binding, event, matchElement }) => {
5
- const startInput = getStartInput(binding, event, matchElement);
6
- const clientData = getClientData(binding, event, matchElement);
7
- const runner = binding.runner;
8
-
9
- const result = typeof runner === "function"
10
- ? runner(startInput, binding.instructions, clientData)
11
- : startInput;
12
-
13
- if (result !== null && result !== undefined && typeof binding.onExtract === "function") {
14
- binding.onExtract(result, event, matchElement);
15
- }
16
-
17
- return result;
18
- };
19
-
20
- export default executeBinding;
21
-
1
+ import getStartInput from "./getStartInput.js";
2
+ import getClientData from "./getClientData.js";
3
+
4
+ const executeBinding = ({ binding, event, matchElement }) => {
5
+ const startInput = getStartInput(binding, event, matchElement);
6
+ const clientData = getClientData(binding, event, matchElement);
7
+ const runner = binding.runner;
8
+
9
+ const result = typeof runner === "function"
10
+ ? runner(startInput, binding.instructions, clientData)
11
+ : startInput;
12
+
13
+ if (result !== null && result !== undefined && typeof binding.onExtract === "function") {
14
+ binding.onExtract(result, event, matchElement);
15
+ }
16
+
17
+ return result;
18
+ };
19
+
20
+ export default executeBinding;
21
+
@@ -1,8 +1,8 @@
1
- const getClientData = (binding, event, matchElement) => ({
2
- ...binding.clientData,
3
- event,
4
- targetElement: matchElement
5
- });
6
-
7
- export default getClientData;
8
-
1
+ const getClientData = (binding, event, matchElement) => ({
2
+ ...binding.clientData,
3
+ event,
4
+ targetElement: matchElement
5
+ });
6
+
7
+ export default getClientData;
8
+
@@ -1,10 +1,10 @@
1
- const getStartInput = (binding, event, matchElement) => {
2
- if (binding.root === "event" || event?.type?.startsWith("key")) {
3
- return event;
4
- }
5
-
6
- return matchElement;
7
- };
8
-
9
- export default getStartInput;
10
-
1
+ const getStartInput = (binding, event, matchElement) => {
2
+ if (binding.root === "event" || event?.type?.startsWith("key")) {
3
+ return event;
4
+ }
5
+
6
+ return matchElement;
7
+ };
8
+
9
+ export default getStartInput;
10
+
@@ -1,15 +1,15 @@
1
- import executeBinding from "./executeBinding.js";
2
-
3
- const dispatchEvent = ({ bindings, event, container }) => {
4
- for (const binding of bindings) {
5
- const matchElement = event.target?.closest?.(binding.selector);
6
- if (!matchElement || !container.contains(matchElement)) {
7
- continue;
8
- }
9
-
10
- executeBinding({ binding, event, matchElement });
11
- }
12
- };
13
-
14
- export default dispatchEvent;
15
-
1
+ import executeBinding from "./executeBinding.js";
2
+
3
+ const dispatchEvent = ({ bindings, event, container }) => {
4
+ for (const binding of bindings) {
5
+ const matchElement = event.target?.closest?.(binding.selector);
6
+ if (!matchElement || !container.contains(matchElement)) {
7
+ continue;
8
+ }
9
+
10
+ executeBinding({ binding, event, matchElement });
11
+ }
12
+ };
13
+
14
+ export default dispatchEvent;
15
+
@@ -1,11 +1,11 @@
1
- import validateArray from "./validateArray.js";
2
-
3
- const checkBindings = (bindings) => {
4
- const valid = validateArray(bindings);
5
- if (valid.length === 0) return null;
6
-
7
- return valid;
8
- };
9
-
10
- export default checkBindings;
11
-
1
+ import validateArray from "./validateArray.js";
2
+
3
+ const checkBindings = (bindings) => {
4
+ const valid = validateArray(bindings);
5
+ if (valid.length === 0) return null;
6
+
7
+ return valid;
8
+ };
9
+
10
+ export default checkBindings;
11
+
@@ -1,10 +1,10 @@
1
- const validateArray = (bindings) => {
2
- if (!Array.isArray(bindings)) return [];
3
-
4
- return bindings.filter((binding) => (
5
- binding && typeof binding === "object" && typeof binding.event === "string" && typeof binding.selector === "string"
6
- ));
7
- };
8
-
9
- export default validateArray;
10
-
1
+ const validateArray = (bindings) => {
2
+ if (!Array.isArray(bindings)) return [];
3
+
4
+ return bindings.filter((binding) => (
5
+ binding && typeof binding === "object" && typeof binding.event === "string" && typeof binding.selector === "string"
6
+ ));
7
+ };
8
+
9
+ export default validateArray;
10
+
@@ -1,13 +1,13 @@
1
- import resolveElement from "./resolveElement.js";
2
-
3
- const checkContainer = (containerOrId) => {
4
- if (!containerOrId) return null;
5
-
6
- const element = resolveElement(containerOrId);
7
- if (!element) return null;
8
-
9
- return element;
10
- };
11
-
12
- export default checkContainer;
13
-
1
+ import resolveElement from "./resolveElement.js";
2
+
3
+ const checkContainer = (containerOrId) => {
4
+ if (!containerOrId) return null;
5
+
6
+ const element = resolveElement(containerOrId);
7
+ if (!element) return null;
8
+
9
+ return element;
10
+ };
11
+
12
+ export default checkContainer;
13
+
@@ -1,14 +1,14 @@
1
- const resolveElement = (containerOrId) => {
2
- if (typeof containerOrId === "string") {
3
- return document.getElementById(containerOrId) || document.querySelector(containerOrId);
4
- }
5
-
6
- if (containerOrId && typeof containerOrId === "object" && "addEventListener" in containerOrId) {
7
- return containerOrId;
8
- }
9
-
10
- return null;
11
- };
12
-
13
- export default resolveElement;
14
-
1
+ const resolveElement = (containerOrId) => {
2
+ if (typeof containerOrId === "string") {
3
+ return document.getElementById(containerOrId) || document.querySelector(containerOrId);
4
+ }
5
+
6
+ if (containerOrId && typeof containerOrId === "object" && "addEventListener" in containerOrId) {
7
+ return containerOrId;
8
+ }
9
+
10
+ return null;
11
+ };
12
+
13
+ export default resolveElement;
14
+