@blotch/angular-lynx-testing-library 22.2.9 → 22.2.11

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.
package/README.md CHANGED
@@ -161,7 +161,7 @@ A `CustomEvent`'s `detail` reaches the handler too: `fireEvent(element, new Cust
161
161
 
162
162
  **Available named helpers:**
163
163
 
164
- `tap` · `longtap` · `touchstart` · `touchmove` · `touchcancel` · `touchend` · `longpress` · `keydown` · `keyup` · `mousedown` · `mouseup` · `mousemove` · `mouseclick` · `mousedblclick` · `mouselongpress` · `wheel` · `scroll` · `scrollend` · `scrolltoupper` · `scrolltolower` · `contentsizechanged` · `scrolltoupperedge` · `scrolltoloweredge` · `scrolltonormalstate` · `focus` · `blur` · `input` · `confirm` · `layoutchange` · `load` · `error` · `bgload` · `bgerror` · `transitionstart` · `transitionend` · `transitioncancel` · `animationend`
164
+ `tap` · `longtap` · `touchstart` · `touchmove` · `touchcancel` · `touchend` · `longpress` · `keydown` · `keyup` · `mousedown` · `mouseup` · `mousemove` · `mouseclick` · `mousedblclick` · `mouselongpress` · `wheel` · `scroll` · `scrollend` · `scrolltoupper` · `scrolltolower` · `contentsizechanged` · `scrolltoupperedge` · `scrolltoloweredge` · `scrolltonormalstate` · `uiappear` · `uidisappear` · `focus` · `blur` · `input` · `confirm` · `layoutchange` · `load` · `error` · `bgload` · `bgerror` · `transitionstart` · `transitionend` · `transitioncancel` · `animationend`
165
165
 
166
166
  ### `eventMap`
167
167
 
@@ -130,6 +130,12 @@ export declare const eventMap: {
130
130
  scrolltonormalstate: {
131
131
  defaultInit: {};
132
132
  };
133
+ uiappear: {
134
+ defaultInit: {};
135
+ };
136
+ uidisappear: {
137
+ defaultInit: {};
138
+ };
133
139
  focus: {
134
140
  defaultInit: {};
135
141
  };
@@ -1 +1 @@
1
- {"version":3,"file":"fire-event.d.ts","sourceRoot":"","sources":["../src/fire-event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;A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AC3D,CAAC,IAAI,SAAS,GAAG,YAAY;CAC/B,CAAC;AA+JF,eAAO,MAAM,SAAS,EAAE,SAET,CAAC"}
@@ -13,7 +13,17 @@
13
13
  * Lynx sends the event (see deliver()).
14
14
  */
15
15
  import { createEvent, fireEvent as domFireEvent, getConfig, } from '@testing-library/dom';
16
- const EVENT_INIT_KEYS = new Set(['bubbles', 'cancelable', 'composed']);
16
+ /**
17
+ * Init keys that aren't copied onto the event: the standard EventInit ones,
18
+ * which are read-only on a constructed event, and `target`, which Testing
19
+ * Library's createEvent sets on the element (`{ target: { value } }`).
20
+ */
21
+ const EVENT_INIT_KEYS = new Set([
22
+ 'bubbles',
23
+ 'cancelable',
24
+ 'composed',
25
+ 'target',
26
+ ]);
17
27
  /**
18
28
  * The events the named helpers fire. Those with `bubbles: true` travel Lynx's
19
29
  * event response chain, from the element up to the page, so a tap on a row
@@ -56,6 +66,11 @@ export const eventMap = {
56
66
  scrolltoupperedge: { defaultInit: {} },
57
67
  scrolltoloweredge: { defaultInit: {} },
58
68
  scrolltonormalstate: { defaultInit: {} },
69
+ // Exposure: an element coming into view, inside its scroll containers and
70
+ // the screen, and leaving it. What `[lynxExposure]` and the runtime's
71
+ // IntersectionObserver listen for.
72
+ uiappear: { defaultInit: {} },
73
+ uidisappear: { defaultInit: {} },
59
74
  // Form / focus
60
75
  focus: { defaultInit: {} },
61
76
  blur: { defaultInit: {} },
@@ -102,11 +117,34 @@ const createLynxEvent = (elem, type, name, init) => {
102
117
  const eventInit = { eventType: type, eventName: name, ...init };
103
118
  const event = createEvent(`${type}:${name}`, elem, eventInit);
104
119
  Object.assign(event, Object.fromEntries(Object.entries(eventInit).filter(([k]) => !EVENT_INIT_KEYS.has(k))));
120
+ // The element the event happened on, by its unique id, as a device names
121
+ // it: the runtime finds a touch's element by it, for the target of the
122
+ // pointer events `document:` listeners get. A DOM event's own `target` is
123
+ // a getter, which the testing environment doesn't copy to the handler, so
124
+ // it's shadowed.
125
+ Object.defineProperty(event, 'target', {
126
+ value: { uid: globalThis.__GetElementUniqueID(elem) },
127
+ enumerable: true,
128
+ configurable: true,
129
+ });
105
130
  return event;
106
131
  };
132
+ /**
133
+ * Every element in `target`'s tree with a `global-bind` handler for `name`:
134
+ * Lynx runs one for an event on any element of the page.
135
+ */
136
+ const globalHandlersOf = (target, name) => {
137
+ let root = target;
138
+ while (root.parentElement)
139
+ root = root.parentElement;
140
+ return [root, ...root.querySelectorAll('*')].filter((element) => handlerOf(element, 'global-bindEvent', name));
141
+ };
107
142
  /**
108
143
  * Runs the handlers for the event `name` fired at `target`, as Lynx's
109
- * TouchEventHandler::HandleEventInternal does on a device. An event that
144
+ * TouchEventHandler::HandleEventInternal does on a device. First every
145
+ * `global-bind` handler for it, on any element: they're what the runtime's
146
+ * `document` and `window` hear the screen's events with, so a `document:` or
147
+ * `window:` listener runs. An event that
110
148
  * bubbles goes down from the page to the target, running `capture-bind` and
111
149
  * `capture-catch` handlers, then back up, running `bind` and `catch` ones. A
112
150
  * `catch` handler of either phase runs and stops the event there. Any other
@@ -153,6 +191,11 @@ const deliver = (target, name, init) => {
153
191
  }
154
192
  return false;
155
193
  };
194
+ for (const element of globalHandlersOf(target, name)) {
195
+ const event = createLynxEvent(target, 'global-bindEvent', name, init);
196
+ handlerOf(element, 'global-bindEvent', name)(event);
197
+ notCanceled &&= !event.defaultPrevented;
198
+ }
156
199
  // Lynx has no capture phase for the events that stay on their target.
157
200
  const captured = !!init['bubbles'] && runPhase([...chain].reverse(), CAPTURE_PHASE);
158
201
  if (!captured)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotch/angular-lynx-testing-library",
3
- "version": "22.2.9",
3
+ "version": "22.2.11",
4
4
  "description": "Testing utilities for AngularLynx apps",
5
5
  "homepage": "https://github.com/Blotch-Smart-Frames/AngularLynx#readme",
6
6
  "bugs": {