dom-primitive-bindings 1.3.1 → 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 (63) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +163 -163
  3. package/package.json +26 -35
  4. package/src/index.js +3 -3
  5. package/src/v2/dispatch/executeBinding.js +21 -0
  6. package/src/v2/dispatch/getClientData.js +8 -0
  7. package/src/v2/dispatch/getStartInput.js +10 -0
  8. package/src/v2/dispatch/index.js +15 -0
  9. package/src/v2/guards/bindings/index.js +11 -0
  10. package/src/v2/guards/bindings/validateArray.js +10 -0
  11. package/src/v2/guards/container/index.js +13 -0
  12. package/src/v2/guards/container/resolveElement.js +14 -0
  13. package/src/v2/guards/index.js +15 -0
  14. package/src/v2/index.js +22 -0
  15. package/src/v2/listeners/attachListener.js +10 -0
  16. package/src/v2/listeners/index.js +12 -0
  17. package/src/v2/prepare/groupBindings.js +14 -0
  18. package/src/v2/prepare/index.js +8 -0
  19. package/src/v2/register/index.js +18 -0
  20. package/src/v2/register/meta.js +6 -0
  21. package/src/v3/dispatch/executeBinding.js +21 -21
  22. package/src/v3/dispatch/getClientData.js +8 -8
  23. package/src/v3/dispatch/getStartInput.js +10 -10
  24. package/src/v3/dispatch/index.js +15 -15
  25. package/src/v3/guards/bindings/index.js +11 -11
  26. package/src/v3/guards/bindings/validateArray.js +10 -10
  27. package/src/v3/guards/container/index.js +13 -13
  28. package/src/v3/guards/container/resolveElement.js +14 -14
  29. package/src/v3/guards/index.js +15 -15
  30. package/src/v3/index.js +22 -22
  31. package/src/v3/listeners/attachListener.js +10 -10
  32. package/src/v3/listeners/index.js +12 -12
  33. package/src/v3/prepare/groupBindings.js +14 -14
  34. package/src/v3/prepare/index.js +8 -8
  35. package/src/v3/register/index.js +18 -18
  36. package/src/v3/register/meta.js +6 -6
  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/architecture.md +0 -111
  54. package/docs/binding-spec.md +0 -86
  55. package/docs/dist/min.js +0 -64
  56. package/docs/dist/v1/min.js +0 -63
  57. package/docs/dist/v2/min.js +0 -64
  58. package/docs/dist/v3/min.js +0 -64
  59. package/docs/index.html +0 -208
  60. package/docs/stories/01-the-listener-trap.html +0 -189
  61. package/docs/stories/02-the-delegation-epiphany.html +0 -185
  62. package/docs/stories/03-the-staged-pipeline.html +0 -162
  63. package/docs/stories/04-declarative-json-bindings.html +0 -159
@@ -0,0 +1,8 @@
1
+ import groupBindings from "./groupBindings.js";
2
+
3
+ const prepareBindings = (bindings) => {
4
+ return groupBindings(bindings);
5
+ };
6
+
7
+ export default prepareBindings;
8
+
@@ -0,0 +1,18 @@
1
+ import meta from "./meta.js";
2
+
3
+ const registerGlobal = (bindEvents, metadata = meta) => {
4
+ if (!bindEvents || typeof globalThis === "undefined") return;
5
+
6
+ globalThis.ks ??= {};
7
+
8
+ globalThis.ks.domPrimitiveBindings = {
9
+ meta: metadata,
10
+ bindEvents
11
+ };
12
+
13
+ globalThis.ks.bindEvents ??= bindEvents;
14
+
15
+ return globalThis.ks.domPrimitiveBindings;
16
+ };
17
+
18
+ export default registerGlobal;
@@ -0,0 +1,6 @@
1
+ export const meta = {
2
+ name: "dom-primitive-bindings",
3
+ version: "3.0.0"
4
+ };
5
+
6
+ export default meta;
@@ -1,111 +0,0 @@
1
- # Architecture & Design Story — DOM Primitive Bindings
2
-
3
- This document details the architectural philosophy, data flow, and design trade-offs behind **DOM Primitive Bindings**.
4
-
5
- ---
6
-
7
- ## 1. The Core Architectural Philosophy
8
-
9
- ### Separation of Concerns: The Wiring Layer vs. The Extraction Layer
10
-
11
- Modern frontend architectures fail when they blur the boundary between **how events are wired** and **how data is extracted or mutated**:
12
-
13
- ```text
14
- ┌─────────────────────────────────┐
15
- │ Browser DOM │ <-- Stateful View (Table, Form, Cards)
16
- └────────────────┬────────────────┘
17
- │ user interaction (click, input, keydown)
18
- ▼
19
- ┌─────────────────────────────────┐
20
- │ dom-primitive-bindings │ <-- Responsibility: The Wiring Layer
21
- │ (guards → prepare → dispatch) │ • Single listener on container
22
- └────────────────┬────────────────┘ • Matches closest(selector)
23
- │ passes { event, targetElement }
24
- ▼
25
- ┌─────────────────────────────────┐
26
- │ dom-primitive-engine │ <-- Responsibility: The Extraction Layer
27
- │ (declarative instructions) │ • Traverses DOM (tr, td)
28
- └────────────────┬────────────────┘ • Produces clean JSON object
29
- │ outputs clean Plain Data
30
- ▼
31
- ┌─────────────────────────────────┐
32
- │ Business Logic / API Call │ <-- Consumes Plain Data
33
- └─────────────────────────────────┘
34
- ```
35
-
36
- By strictly separating event wiring into `dom-primitive-bindings`:
37
- 1. **Zero DOM manipulation**: Bindings never alter, insert, or delete DOM elements.
38
- 2. **Zero schema extraction**: Bindings never parse table cells or form schemas into business models.
39
- 3. **Pure delegation**: Exactly **one listener per event type** is attached to the parent container. Bubbling handles target matching.
40
-
41
- ---
42
-
43
- ## 2. Why Delegated Bindings over Element Listeners?
44
-
45
- | Approach | Memory Usage | Dynamic Element Support | Duplicate Fire Risk |
46
- | :--- | :--- | :--- | :--- |
47
- | **Direct Listeners** (`element.addEventListener`) | High ($O(N)$ listeners) | Fails on newly added DOM elements | High (re-attaching duplicates listeners) |
48
- | **DOM Primitive Bindings** (Container Delegation) | Minimal ($O(1)$ listener per event type) | Works instantly on dynamic elements | Zero (single stable container listener) |
49
-
50
- ---
51
-
52
- ## 3. The 4-Stage Internal Pipeline (`src/v3/`)
53
-
54
- The engine operates on a strictly staged, functional pipeline where every folder contains an `index.js` and exports a single function as `default`:
55
-
56
- ```text
57
- src/v3/
58
- ├── guards/ # Validates container & bindings array
59
- │ ├── container/ # Resolves 1st input (container ID or DOM element)
60
- │ ├── bindings/ # Filters and validates 2nd input (bindings array)
61
- │ └── index.js
62
- ├── prepare/ # Groups bindings by event type into Map
63
- │ ├── groupBindings.js
64
- │ └── index.js
65
- ├── listeners/ # Attaches single container listener per event type
66
- │ ├── attachListener.js
67
- │ └── index.js
68
- ├── dispatch/ # Handles event bubbling, target matching & execution
69
- │ ├── getStartInput.js
70
- │ ├── getClientData.js
71
- │ ├── executeBinding.js
72
- │ └── index.js
73
- ├── register/ # Exposes module onto window.ks.domPrimitiveBindings
74
- │ ├── meta.js
75
- │ └── index.js
76
- └── index.js # Orchestrator
77
- ```
78
-
79
- ### Stage Details
80
-
81
- 1. **`guards/`**: Validates inputs before any DOM mutation occurs.
82
- - `container/`: Resolves string IDs via `document.getElementById` or verifies existing element.
83
- - `bindings/`: Filters invalid items and ensures at least one valid binding exists.
84
- 2. **`prepare/`**: Groups bindings into a `Map<eventType, bindings[]>`.
85
- - If 10 separate selectors listen for `click`, they are aggregated under the single `"click"` event group.
86
- 3. **`listeners/`**: Attaches exactly one native event listener to the container per event type.
87
- 4. **`dispatch/`**:
88
- - Intercepts the bubbling event.
89
- - Resolves matching element via `event.target.closest(binding.selector)`.
90
- - Resolves starting input (`event` for keyboard events, `matchElement` for clicks).
91
- - Invokes runner and forwards data to `onExtract`.
92
-
93
- ---
94
-
95
- ## 4. Responsibility Boundaries
96
-
97
- | Actor | What It Does | What It NEVER Does |
98
- | :--- | :--- | :--- |
99
- | **Container Element** | Acts as the stable anchor for bubbling events | Does not know about inner button schemas |
100
- | **`bindings.json`** | Declares `event` and `selector` | Does not execute imperative logic |
101
- | **`dom-primitive-bindings`** | Resolves target, manages delegation pipeline | Does not extract table rows or mutate markup |
102
- | **`dom-primitive-engine`** | Extracts clean JSON data from the matched target | Does not manage event listeners |
103
-
104
- ---
105
-
106
- ## 5. Version Evolution (`v3` as Single Source of Truth)
107
-
108
- - **v1**: Staged architecture established with zero code comments and single-function default exports.
109
- - **v2**: Removed accidental DOM manipulation and cell extraction from samples, solidifying the pure delegation boundary.
110
- - **v3**: Declarative JSON transformation. Replaced imperative `.js` event arrays with pure, serializable `bindings.json` configurations.
111
-
@@ -1,86 +0,0 @@
1
- # Binding Specification — DOM Primitive Bindings
2
-
3
- This document defines the normative schema and runtime behavior for declarative `bindings.json` files.
4
-
5
- ---
6
-
7
- ## 1. Schema Overview
8
-
9
- A bindings file is an array of binding specification objects:
10
-
11
- ```json
12
- [
13
- {
14
- "event": "click",
15
- "selector": ".ks-btn-show",
16
- "root": "element",
17
- "clientData": {
18
- "context": "tableRow"
19
- }
20
- }
21
- ]
22
- ```
23
-
24
- ---
25
-
26
- ## 2. Property Definitions
27
-
28
- ### `event` (Required)
29
- - **Type**: `string`
30
- - **Description**: The standard browser DOM event name to listen for on the container (e.g. `"click"`, `"keydown"`, `"input"`, `"change"`, `"submit"`).
31
- - **Behavior**: The engine groups all bindings with the same `event` name under a single native event listener on the container element.
32
-
33
- ### `selector` (Required)
34
- - **Type**: `string`
35
- - **Description**: Standard CSS selector used by `event.target.closest(selector)` to identify whether the bubbling event originated from or within a target element.
36
- - **Examples**:
37
- - `".ks-btn-show"`
38
- - `"input[type='search'], input"`
39
- - `".btn-action"`
40
- - `".product-card"`
41
-
42
- ### `root` (Optional)
43
- - **Type**: `string` (`"element"` | `"event"`)
44
- - **Default**: `"element"` (automatically defaults to `"event"` for key events such as `keydown`, `keyup`, `keypress`).
45
- - **Description**: Determines what is passed as the first argument to the runner function:
46
- - `"element"`: passes the matched DOM element (`matchElement`).
47
- - `"event"`: passes the native browser `Event` object.
48
-
49
- ### `clientData` (Optional)
50
- - **Type**: `object`
51
- - **Description**: Arbitrary user-defined context passed along into the dispatch pipeline. The engine merges this into the client context object alongside `event` and `targetElement`.
52
-
53
- ### `instructions` (Optional)
54
- - **Type**: `array`
55
- - **Description**: Declarative extraction instructions intended for handoff to `dom-primitive-engine`.
56
-
57
- ---
58
-
59
- ## 3. Runtime Dispatch Lifecycle
60
-
61
- When an event fires inside the container:
62
-
63
- ```text
64
- Browser Event Fires
65
- │
66
- ▼
67
- Container Listener Intercepts (listeners/attachListener.js)
68
- │
69
- ▼
70
- Find Matching Element: event.target.closest(binding.selector)
71
- │
72
- ├── No match / not inside container ──> Discard (continue)
73
- │
74
- ▼
75
- Resolve Start Input (dispatch/getStartInput.js)
76
- │
77
- ├── Key event or root === "event" ──> Pass event
78
- └── Otherwise ──> Pass matchElement
79
- │
80
- ▼
81
- Execute Runner (dispatch/executeBinding.js)
82
- │
83
- ▼
84
- Forward to onExtract(result, event, matchElement)
85
- ```
86
-
package/docs/dist/min.js DELETED
@@ -1,64 +0,0 @@
1
- const u = {
2
- name: "dom-primitive-bindings",
3
- version: "3.0.0"
4
- }, c = (t, n = u) => {
5
- var e;
6
- if (!(!t || typeof globalThis > "u"))
7
- return globalThis.ks ?? (globalThis.ks = {}), globalThis.ks.domPrimitiveBindings = {
8
- meta: n,
9
- bindEvents: t
10
- }, (e = globalThis.ks).bindEvents ?? (e.bindEvents = t), globalThis.ks.domPrimitiveBindings;
11
- }, l = (t) => typeof t == "string" ? document.getElementById(t) || document.querySelector(t) : t && typeof t == "object" && "addEventListener" in t ? t : null, a = (t) => {
12
- if (!t) return null;
13
- const n = l(t);
14
- return n || null;
15
- }, f = (t) => Array.isArray(t) ? t.filter((n) => n && typeof n == "object" && typeof n.event == "string" && typeof n.selector == "string") : [], g = (t) => {
16
- const n = f(t);
17
- return n.length === 0 ? null : n;
18
- }, p = (t, n) => {
19
- const e = a(t);
20
- if (!e) return null;
21
- const r = g(n);
22
- return r ? { container: e, bindings: r } : null;
23
- }, d = (t) => {
24
- const n = /* @__PURE__ */ new Map();
25
- for (const e of t) {
26
- const r = n.get(e.event) ?? [];
27
- r.push(e), n.set(e.event, r);
28
- }
29
- return n;
30
- }, y = (t) => d(t), m = (t, n, e) => {
31
- var r;
32
- return t.root === "event" || (r = n == null ? void 0 : n.type) != null && r.startsWith("key") ? n : e;
33
- }, h = (t, n, e) => ({
34
- ...t.clientData,
35
- event: n,
36
- targetElement: e
37
- }), v = ({ binding: t, event: n, matchElement: e }) => {
38
- const r = m(t, n, e), i = h(t, n, e), o = t.runner, s = typeof o == "function" ? o(r, t.instructions, i) : r;
39
- return s != null && typeof t.onExtract == "function" && t.onExtract(s, n, e), s;
40
- }, B = ({ bindings: t, event: n, container: e }) => {
41
- var r, i;
42
- for (const o of t) {
43
- const s = (i = (r = n.target) == null ? void 0 : r.closest) == null ? void 0 : i.call(r, o.selector);
44
- !s || !e.contains(s) || v({ binding: o, event: n, matchElement: s });
45
- }
46
- }, k = (t, n, e) => {
47
- t.addEventListener(n, (r) => {
48
- B({ bindings: e, event: r, container: t });
49
- });
50
- }, E = (t, n) => {
51
- for (const [e, r] of n.entries())
52
- k(t, e, r);
53
- return t;
54
- }, T = (t, n = []) => {
55
- const e = p(t, n);
56
- if (!e) return null;
57
- const { container: r, bindings: i } = e, o = y(i);
58
- return E(r, o), r;
59
- };
60
- c(T);
61
- export {
62
- T as bindEvents,
63
- T as default
64
- };
@@ -1,63 +0,0 @@
1
- const u = {
2
- name: "dom-primitive-bindings",
3
- version: "1.0.0"
4
- }, c = (t, n = u) => {
5
- if (!(!t || typeof globalThis > "u"))
6
- return globalThis.ks ?? (globalThis.ks = {}), globalThis.ks.domPrimitiveBindings = {
7
- meta: n,
8
- bindEvents: t
9
- }, globalThis.ks.domPrimitiveBindings;
10
- }, l = (t) => typeof t == "string" ? document.getElementById(t) || document.querySelector(t) : t && typeof t == "object" && "addEventListener" in t ? t : null, a = (t) => {
11
- if (!t) return null;
12
- const n = l(t);
13
- return n || null;
14
- }, f = (t) => Array.isArray(t) ? t.filter((n) => n && typeof n == "object" && typeof n.event == "string" && typeof n.selector == "string") : [], g = (t) => {
15
- const n = f(t);
16
- return n.length === 0 ? null : n;
17
- }, p = (t, n) => {
18
- const e = a(t);
19
- if (!e) return null;
20
- const r = g(n);
21
- return r ? { container: e, bindings: r } : null;
22
- }, d = (t) => {
23
- const n = /* @__PURE__ */ new Map();
24
- for (const e of t) {
25
- const r = n.get(e.event) ?? [];
26
- r.push(e), n.set(e.event, r);
27
- }
28
- return n;
29
- }, y = (t) => d(t), m = (t, n, e) => {
30
- var r;
31
- return t.root === "event" || (r = n == null ? void 0 : n.type) != null && r.startsWith("key") ? n : e;
32
- }, h = (t, n, e) => ({
33
- ...t.clientData,
34
- event: n,
35
- targetElement: e
36
- }), v = ({ binding: t, event: n, matchElement: e }) => {
37
- const r = m(t, n, e), i = h(t, n, e), o = t.runner, s = typeof o == "function" ? o(r, t.instructions, i) : r;
38
- return s != null && typeof t.onExtract == "function" && t.onExtract(s, n, e), s;
39
- }, B = ({ bindings: t, event: n, container: e }) => {
40
- var r, i;
41
- for (const o of t) {
42
- const s = (i = (r = n.target) == null ? void 0 : r.closest) == null ? void 0 : i.call(r, o.selector);
43
- !s || !e.contains(s) || v({ binding: o, event: n, matchElement: s });
44
- }
45
- }, E = (t, n, e) => {
46
- t.addEventListener(n, (r) => {
47
- B({ bindings: e, event: r, container: t });
48
- });
49
- }, k = (t, n) => {
50
- for (const [e, r] of n.entries())
51
- E(t, e, r);
52
- return t;
53
- }, T = (t, n = []) => {
54
- const e = p(t, n);
55
- if (!e) return null;
56
- const { container: r, bindings: i } = e, o = y(i);
57
- return k(r, o), r;
58
- };
59
- c(T);
60
- export {
61
- T as bindEvents,
62
- T as default
63
- };
@@ -1,64 +0,0 @@
1
- const u = {
2
- name: "dom-primitive-bindings",
3
- version: "2.0.0"
4
- }, c = (t, n = u) => {
5
- var e;
6
- if (!(!t || typeof globalThis > "u"))
7
- return globalThis.ks ?? (globalThis.ks = {}), globalThis.ks.domPrimitiveBindings = {
8
- meta: n,
9
- bindEvents: t
10
- }, (e = globalThis.ks).bindEvents ?? (e.bindEvents = t), globalThis.ks.domPrimitiveBindings;
11
- }, l = (t) => typeof t == "string" ? document.getElementById(t) || document.querySelector(t) : t && typeof t == "object" && "addEventListener" in t ? t : null, a = (t) => {
12
- if (!t) return null;
13
- const n = l(t);
14
- return n || null;
15
- }, f = (t) => Array.isArray(t) ? t.filter((n) => n && typeof n == "object" && typeof n.event == "string" && typeof n.selector == "string") : [], g = (t) => {
16
- const n = f(t);
17
- return n.length === 0 ? null : n;
18
- }, p = (t, n) => {
19
- const e = a(t);
20
- if (!e) return null;
21
- const r = g(n);
22
- return r ? { container: e, bindings: r } : null;
23
- }, d = (t) => {
24
- const n = /* @__PURE__ */ new Map();
25
- for (const e of t) {
26
- const r = n.get(e.event) ?? [];
27
- r.push(e), n.set(e.event, r);
28
- }
29
- return n;
30
- }, y = (t) => d(t), m = (t, n, e) => {
31
- var r;
32
- return t.root === "event" || (r = n == null ? void 0 : n.type) != null && r.startsWith("key") ? n : e;
33
- }, h = (t, n, e) => ({
34
- ...t.clientData,
35
- event: n,
36
- targetElement: e
37
- }), v = ({ binding: t, event: n, matchElement: e }) => {
38
- const r = m(t, n, e), i = h(t, n, e), o = t.runner, s = typeof o == "function" ? o(r, t.instructions, i) : r;
39
- return s != null && typeof t.onExtract == "function" && t.onExtract(s, n, e), s;
40
- }, B = ({ bindings: t, event: n, container: e }) => {
41
- var r, i;
42
- for (const o of t) {
43
- const s = (i = (r = n.target) == null ? void 0 : r.closest) == null ? void 0 : i.call(r, o.selector);
44
- !s || !e.contains(s) || v({ binding: o, event: n, matchElement: s });
45
- }
46
- }, k = (t, n, e) => {
47
- t.addEventListener(n, (r) => {
48
- B({ bindings: e, event: r, container: t });
49
- });
50
- }, E = (t, n) => {
51
- for (const [e, r] of n.entries())
52
- k(t, e, r);
53
- return t;
54
- }, T = (t, n = []) => {
55
- const e = p(t, n);
56
- if (!e) return null;
57
- const { container: r, bindings: i } = e, o = y(i);
58
- return E(r, o), r;
59
- };
60
- c(T);
61
- export {
62
- T as bindEvents,
63
- T as default
64
- };
@@ -1,64 +0,0 @@
1
- const u = {
2
- name: "dom-primitive-bindings",
3
- version: "3.0.0"
4
- }, c = (t, n = u) => {
5
- var e;
6
- if (!(!t || typeof globalThis > "u"))
7
- return globalThis.ks ?? (globalThis.ks = {}), globalThis.ks.domPrimitiveBindings = {
8
- meta: n,
9
- bindEvents: t
10
- }, (e = globalThis.ks).bindEvents ?? (e.bindEvents = t), globalThis.ks.domPrimitiveBindings;
11
- }, l = (t) => typeof t == "string" ? document.getElementById(t) || document.querySelector(t) : t && typeof t == "object" && "addEventListener" in t ? t : null, a = (t) => {
12
- if (!t) return null;
13
- const n = l(t);
14
- return n || null;
15
- }, f = (t) => Array.isArray(t) ? t.filter((n) => n && typeof n == "object" && typeof n.event == "string" && typeof n.selector == "string") : [], g = (t) => {
16
- const n = f(t);
17
- return n.length === 0 ? null : n;
18
- }, p = (t, n) => {
19
- const e = a(t);
20
- if (!e) return null;
21
- const r = g(n);
22
- return r ? { container: e, bindings: r } : null;
23
- }, d = (t) => {
24
- const n = /* @__PURE__ */ new Map();
25
- for (const e of t) {
26
- const r = n.get(e.event) ?? [];
27
- r.push(e), n.set(e.event, r);
28
- }
29
- return n;
30
- }, y = (t) => d(t), m = (t, n, e) => {
31
- var r;
32
- return t.root === "event" || (r = n == null ? void 0 : n.type) != null && r.startsWith("key") ? n : e;
33
- }, h = (t, n, e) => ({
34
- ...t.clientData,
35
- event: n,
36
- targetElement: e
37
- }), v = ({ binding: t, event: n, matchElement: e }) => {
38
- const r = m(t, n, e), i = h(t, n, e), o = t.runner, s = typeof o == "function" ? o(r, t.instructions, i) : r;
39
- return s != null && typeof t.onExtract == "function" && t.onExtract(s, n, e), s;
40
- }, B = ({ bindings: t, event: n, container: e }) => {
41
- var r, i;
42
- for (const o of t) {
43
- const s = (i = (r = n.target) == null ? void 0 : r.closest) == null ? void 0 : i.call(r, o.selector);
44
- !s || !e.contains(s) || v({ binding: o, event: n, matchElement: s });
45
- }
46
- }, k = (t, n, e) => {
47
- t.addEventListener(n, (r) => {
48
- B({ bindings: e, event: r, container: t });
49
- });
50
- }, E = (t, n) => {
51
- for (const [e, r] of n.entries())
52
- k(t, e, r);
53
- return t;
54
- }, T = (t, n = []) => {
55
- const e = p(t, n);
56
- if (!e) return null;
57
- const { container: r, bindings: i } = e, o = y(i);
58
- return E(r, o), r;
59
- };
60
- c(T);
61
- export {
62
- T as bindEvents,
63
- T as default
64
- };