@angular/core 20.0.0-next.1 → 20.0.0-next.3
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/fesm2022/core.mjs +770 -2144
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/di.mjs +3 -2
- package/fesm2022/primitives/di.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +2 -589
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +44 -13
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +7 -39
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +116 -143
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/weak_ref-DrMdAIDh.mjs +12 -0
- package/fesm2022/weak_ref-DrMdAIDh.mjs.map +1 -0
- package/index.d.ts +14366 -15214
- package/navigation_types.d-u4EOrrdZ.d.ts +121 -0
- package/package.json +2 -2
- package/primitives/di/index.d.ts +66 -59
- package/primitives/event-dispatch/index.d.ts +205 -309
- package/primitives/signals/index.d.ts +161 -195
- package/rxjs-interop/index.d.ts +71 -100
- package/schematics/bundles/{apply_import_manager-e2a7fe5b.js → apply_import_manager-BXQEjo09.js} +15 -19
- package/schematics/bundles/{checker-af521da6.js → checker-BHb19MHt.js} +3695 -1175
- package/schematics/bundles/cleanup-unused-imports.js +56 -89
- package/schematics/bundles/{compiler_host-5a29293c.js → compiler_host-Bk3repE2.js} +19 -23
- package/schematics/bundles/control-flow-migration.js +81 -38
- package/schematics/bundles/{imports-047fbbc8.js → imports-CIX-JgAN.js} +9 -14
- package/schematics/bundles/{index-1bef3025.js → index-BL9kAIe5.js} +62 -66
- package/schematics/bundles/{program-a449f9bf.js → index-I8VbxQcO.js} +1508 -3178
- package/schematics/bundles/inject-flags.js +147 -0
- package/schematics/bundles/inject-migration.js +121 -127
- package/schematics/bundles/{leading_space-f8944434.js → leading_space-D9nQ8UQC.js} +1 -1
- package/schematics/bundles/{migrate_ts_type_references-2a3e9e6b.js → migrate_ts_type_references-KlOTWeDl.js} +121 -126
- package/schematics/bundles/{ng_decorators-b0d8b324.js → ng_decorators-DznZ5jMl.js} +4 -8
- package/schematics/bundles/{nodes-7758dbf6.js → nodes-B16H9JUd.js} +2 -6
- package/schematics/bundles/output-migration.js +94 -128
- package/schematics/bundles/{project_tsconfig_paths-b558633b.js → project_tsconfig_paths-CDVxT6Ov.js} +1 -1
- package/schematics/bundles/{property_name-ac18447e.js → property_name-BBwFuqMe.js} +3 -7
- package/schematics/bundles/route-lazy-loading.js +35 -41
- package/schematics/bundles/{project_paths-17dc204d.js → run_in_devkit-C0JPtK2u.js} +283 -216
- package/schematics/bundles/self-closing-tags-migration.js +55 -91
- package/schematics/bundles/signal-input-migration.js +121 -156
- package/schematics/bundles/signal-queries-migration.js +119 -154
- package/schematics/bundles/signals.js +12 -14
- package/schematics/bundles/standalone-migration.js +180 -200
- package/schematics/bundles/symbol-VPWguRxr.js +25 -0
- package/schematics/bundles/test-bed-get.js +98 -0
- package/schematics/migrations.json +8 -14
- package/testing/index.d.ts +289 -471
- package/weak_ref.d-ttyj86RV.d.ts +9 -0
- package/schematics/bundles/explicit-standalone-flag.js +0 -184
- package/schematics/bundles/index-ef1bffbb.js +0 -30
- package/schematics/bundles/pending-tasks.js +0 -103
- package/schematics/bundles/provide-initializer.js +0 -186
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v20.0.0-next.
|
|
2
|
+
* @license Angular v20.0.0-next.3
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -83,16 +83,6 @@ function getParsed(text) {
|
|
|
83
83
|
function setParsed(text, parsed) {
|
|
84
84
|
parseCache[text] = parsed;
|
|
85
85
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Clears the jsaction parser cache from the given DOM Element.
|
|
88
|
-
*
|
|
89
|
-
* @param element .
|
|
90
|
-
*/
|
|
91
|
-
function clear(element) {
|
|
92
|
-
if (Property.JSACTION in element) {
|
|
93
|
-
delete element[Property.JSACTION];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
86
|
|
|
97
87
|
/*
|
|
98
88
|
* Names of events that are special to jsaction. These are not all
|
|
@@ -104,16 +94,6 @@ function clear(element) {
|
|
|
104
94
|
* event contract doesn't work around their peculiarities.
|
|
105
95
|
*/
|
|
106
96
|
const EventType = {
|
|
107
|
-
/**
|
|
108
|
-
* Mouse middle click, introduced in Chrome 55 and not yet supported on
|
|
109
|
-
* other browsers.
|
|
110
|
-
*/
|
|
111
|
-
AUXCLICK: 'auxclick',
|
|
112
|
-
/**
|
|
113
|
-
* The change event fired by browsers when the `value` attribute of input,
|
|
114
|
-
* select, and textarea elements are changed.
|
|
115
|
-
*/
|
|
116
|
-
CHANGE: 'change',
|
|
117
97
|
/**
|
|
118
98
|
* The click event. In addEvent() refers to all click events, in the
|
|
119
99
|
* jsaction attribute it refers to the unmodified click and Enter/Space
|
|
@@ -128,12 +108,6 @@ const EventType = {
|
|
|
128
108
|
* click event.
|
|
129
109
|
*/
|
|
130
110
|
CLICKMOD: 'clickmod',
|
|
131
|
-
/**
|
|
132
|
-
* Specifies the jsaction for a click-only event. Click-only doesn't take
|
|
133
|
-
* into account the case where an element with focus receives an Enter/Space
|
|
134
|
-
* keypress. This event isn't separately enabled in addEvent().
|
|
135
|
-
*/
|
|
136
|
-
CLICKONLY: 'clickonly',
|
|
137
111
|
/**
|
|
138
112
|
* The dblclick event.
|
|
139
113
|
*/
|
|
@@ -183,18 +157,6 @@ const EventType = {
|
|
|
183
157
|
* browsers.
|
|
184
158
|
*/
|
|
185
159
|
KEYUP: 'keyup',
|
|
186
|
-
/**
|
|
187
|
-
* The mouseup event. Can either be used directly or used implicitly to
|
|
188
|
-
* capture mouseup events. In addEvent(), it represents a regular DOM
|
|
189
|
-
* mouseup event.
|
|
190
|
-
*/
|
|
191
|
-
MOUSEUP: 'mouseup',
|
|
192
|
-
/**
|
|
193
|
-
* The mousedown event. Can either be used directly or used implicitly to
|
|
194
|
-
* capture mouseenter events. In addEvent(), it represents a regular DOM
|
|
195
|
-
* mouseover event.
|
|
196
|
-
*/
|
|
197
|
-
MOUSEDOWN: 'mousedown',
|
|
198
160
|
/**
|
|
199
161
|
* The mouseover event. Can either be used directly or used implicitly to
|
|
200
162
|
* capture mouseenter events. In addEvent(), it represents a regular DOM
|
|
@@ -217,22 +179,6 @@ const EventType = {
|
|
|
217
179
|
* element being entered within a DOM tree.
|
|
218
180
|
*/
|
|
219
181
|
MOUSELEAVE: 'mouseleave',
|
|
220
|
-
/**
|
|
221
|
-
* The mousemove event.
|
|
222
|
-
*/
|
|
223
|
-
MOUSEMOVE: 'mousemove',
|
|
224
|
-
/**
|
|
225
|
-
* The pointerup event. Can either be used directly or used implicitly to
|
|
226
|
-
* capture pointerup events. In addEvent(), it represents a regular DOM
|
|
227
|
-
* pointerup event.
|
|
228
|
-
*/
|
|
229
|
-
POINTERUP: 'pointerup',
|
|
230
|
-
/**
|
|
231
|
-
* The pointerdown event. Can either be used directly or used implicitly to
|
|
232
|
-
* capture pointerenter events. In addEvent(), it represents a regular DOM
|
|
233
|
-
* mouseover event.
|
|
234
|
-
*/
|
|
235
|
-
POINTERDOWN: 'pointerdown',
|
|
236
182
|
/**
|
|
237
183
|
* The pointerover event. Can either be used directly or used implicitly to
|
|
238
184
|
* capture pointerenter events. In addEvent(), it represents a regular DOM
|
|
@@ -255,26 +201,6 @@ const EventType = {
|
|
|
255
201
|
* element being entered within a DOM tree.
|
|
256
202
|
*/
|
|
257
203
|
POINTERLEAVE: 'pointerleave',
|
|
258
|
-
/**
|
|
259
|
-
* The pointermove event.
|
|
260
|
-
*/
|
|
261
|
-
POINTERMOVE: 'pointermove',
|
|
262
|
-
/**
|
|
263
|
-
* The pointercancel event.
|
|
264
|
-
*/
|
|
265
|
-
POINTERCANCEL: 'pointercancel',
|
|
266
|
-
/**
|
|
267
|
-
* The gotpointercapture event is fired when
|
|
268
|
-
* Element.setPointerCapture(pointerId) is called on a mouse input, or
|
|
269
|
-
* implicitly when a touch input begins.
|
|
270
|
-
*/
|
|
271
|
-
GOTPOINTERCAPTURE: 'gotpointercapture',
|
|
272
|
-
/**
|
|
273
|
-
* The lostpointercapture event is fired when
|
|
274
|
-
* Element.releasePointerCapture(pointerId) is called, or implicitly after a
|
|
275
|
-
* touch input ends.
|
|
276
|
-
*/
|
|
277
|
-
LOSTPOINTERCAPTURE: 'lostpointercapture',
|
|
278
204
|
/**
|
|
279
205
|
* The error event. The error event doesn't bubble, but you can use it in
|
|
280
206
|
* addEvent() and jsaction anyway. EventContract does the right thing under
|
|
@@ -287,10 +213,6 @@ const EventType = {
|
|
|
287
213
|
* under the hood.
|
|
288
214
|
*/
|
|
289
215
|
LOAD: 'load',
|
|
290
|
-
/**
|
|
291
|
-
* The unload event.
|
|
292
|
-
*/
|
|
293
|
-
UNLOAD: 'unload',
|
|
294
216
|
/**
|
|
295
217
|
* The touchstart event. Bubbles, will only ever fire in browsers with
|
|
296
218
|
* touch support.
|
|
@@ -306,30 +228,12 @@ const EventType = {
|
|
|
306
228
|
* touch support.
|
|
307
229
|
*/
|
|
308
230
|
TOUCHMOVE: 'touchmove',
|
|
309
|
-
/**
|
|
310
|
-
* The input event.
|
|
311
|
-
*/
|
|
312
|
-
INPUT: 'input',
|
|
313
|
-
/**
|
|
314
|
-
* The scroll event.
|
|
315
|
-
*/
|
|
316
|
-
SCROLL: 'scroll',
|
|
317
231
|
/**
|
|
318
232
|
* The toggle event. The toggle event doesn't bubble, but you can use it in
|
|
319
233
|
* addEvent() and jsaction anyway. EventContract does the right thing
|
|
320
234
|
* under the hood.
|
|
321
235
|
*/
|
|
322
|
-
TOGGLE: 'toggle'
|
|
323
|
-
/**
|
|
324
|
-
* A custom event. The actual custom event type is declared as the 'type'
|
|
325
|
-
* field in the event details. Supported in Firefox 6+, IE 9+, and all Chrome
|
|
326
|
-
* versions.
|
|
327
|
-
*
|
|
328
|
-
* This is an internal name. Users should use jsaction's fireCustomEvent to
|
|
329
|
-
* fire custom events instead of relying on this type to create them.
|
|
330
|
-
*/
|
|
331
|
-
CUSTOM: '_custom',
|
|
332
|
-
};
|
|
236
|
+
TOGGLE: 'toggle'};
|
|
333
237
|
/** All event types that do not bubble or capture and need a polyfill. */
|
|
334
238
|
const MOUSE_SPECIAL_EVENT_TYPES = [
|
|
335
239
|
EventType.MOUSEENTER,
|
|
@@ -413,18 +317,6 @@ const EARLY_EVENT_TYPES = BUBBLE_EVENT_TYPES.concat(CAPTURE_EVENT_TYPES);
|
|
|
413
317
|
*/
|
|
414
318
|
const isEarlyEventType = (eventType) => EARLY_EVENT_TYPES.indexOf(eventType) >= 0;
|
|
415
319
|
|
|
416
|
-
/**
|
|
417
|
-
* If on a Macintosh with an extended keyboard, the Enter key located in the
|
|
418
|
-
* numeric pad has a different ASCII code.
|
|
419
|
-
*/
|
|
420
|
-
const MAC_ENTER = 3;
|
|
421
|
-
/** The Enter key. */
|
|
422
|
-
const ENTER = 13;
|
|
423
|
-
/** The Space key. */
|
|
424
|
-
const SPACE = 32;
|
|
425
|
-
/** Special keycodes used by jsaction for the generic click action. */
|
|
426
|
-
const KeyCode = { MAC_ENTER, ENTER, SPACE };
|
|
427
|
-
|
|
428
320
|
/**
|
|
429
321
|
* Gets a browser event type, if it would differ from the JSAction event type.
|
|
430
322
|
*/
|
|
@@ -504,13 +396,6 @@ function removeEventListener(element, info) {
|
|
|
504
396
|
element.detachEvent(`on${info.eventType}`, info.handler);
|
|
505
397
|
}
|
|
506
398
|
}
|
|
507
|
-
/**
|
|
508
|
-
* Cancels propagation of an event.
|
|
509
|
-
* @param e The event to cancel propagation for.
|
|
510
|
-
*/
|
|
511
|
-
function stopPropagation(e) {
|
|
512
|
-
e.stopPropagation ? e.stopPropagation() : (e.cancelBubble = true);
|
|
513
|
-
}
|
|
514
399
|
/**
|
|
515
400
|
* Prevents the default action of an event.
|
|
516
401
|
* @param e The event to prevent the default action for.
|
|
@@ -518,22 +403,6 @@ function stopPropagation(e) {
|
|
|
518
403
|
function preventDefault(e) {
|
|
519
404
|
e.preventDefault ? e.preventDefault() : (e.returnValue = false);
|
|
520
405
|
}
|
|
521
|
-
/**
|
|
522
|
-
* Gets the target Element of the event. In Firefox, a text node may appear as
|
|
523
|
-
* the target of the event, in which case we return the parent element of the
|
|
524
|
-
* text node.
|
|
525
|
-
* @param e The event to get the target of.
|
|
526
|
-
* @return The target element.
|
|
527
|
-
*/
|
|
528
|
-
function getTarget(e) {
|
|
529
|
-
let el = e.target;
|
|
530
|
-
// In Firefox, the event may have a text node as its target. We always
|
|
531
|
-
// want the parent Element the text node belongs to, however.
|
|
532
|
-
if (!el.getAttribute && el.parentNode) {
|
|
533
|
-
el = el.parentNode;
|
|
534
|
-
}
|
|
535
|
-
return el;
|
|
536
|
-
}
|
|
537
406
|
/**
|
|
538
407
|
* Whether we are on a Mac. Not pulling in useragent just for this.
|
|
539
408
|
*/
|
|
@@ -571,177 +440,6 @@ function isModifiedClickEvent(e) {
|
|
|
571
440
|
// `shiftKey` is an old DOM API.
|
|
572
441
|
e.shiftKey);
|
|
573
442
|
}
|
|
574
|
-
/** Whether we are on WebKit (e.g., Chrome). */
|
|
575
|
-
const isWebKit = typeof navigator !== 'undefined' &&
|
|
576
|
-
!/Opera/.test(navigator.userAgent) &&
|
|
577
|
-
/WebKit/.test(navigator.userAgent);
|
|
578
|
-
/** Whether we are on IE. */
|
|
579
|
-
const isIe = typeof navigator !== 'undefined' &&
|
|
580
|
-
(/MSIE/.test(navigator.userAgent) || /Trident/.test(navigator.userAgent));
|
|
581
|
-
/** Whether we are on Gecko (e.g., Firefox). */
|
|
582
|
-
const isGecko = typeof navigator !== 'undefined' &&
|
|
583
|
-
!/Opera|WebKit/.test(navigator.userAgent) &&
|
|
584
|
-
/Gecko/.test(navigator.product);
|
|
585
|
-
/**
|
|
586
|
-
* Determines and returns whether the given element is a valid target for
|
|
587
|
-
* keypress/keydown DOM events that act like regular DOM clicks.
|
|
588
|
-
* @param el The element.
|
|
589
|
-
* @return Whether the given element is a valid action key target.
|
|
590
|
-
*/
|
|
591
|
-
function isValidActionKeyTarget(el) {
|
|
592
|
-
if (!('getAttribute' in el)) {
|
|
593
|
-
return false;
|
|
594
|
-
}
|
|
595
|
-
if (isTextControl(el)) {
|
|
596
|
-
return false;
|
|
597
|
-
}
|
|
598
|
-
if (isNativelyActivatable(el)) {
|
|
599
|
-
return false;
|
|
600
|
-
}
|
|
601
|
-
// `isContentEditable` is an old DOM API.
|
|
602
|
-
if (el.isContentEditable) {
|
|
603
|
-
return false;
|
|
604
|
-
}
|
|
605
|
-
return true;
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* Whether an event has a modifier key activated.
|
|
609
|
-
* @param e The event.
|
|
610
|
-
* @return True, if a modifier key is activated.
|
|
611
|
-
*/
|
|
612
|
-
function hasModifierKey(e) {
|
|
613
|
-
return (
|
|
614
|
-
// `ctrlKey` is an old DOM API.
|
|
615
|
-
e.ctrlKey ||
|
|
616
|
-
// `shiftKey` is an old DOM API.
|
|
617
|
-
e.shiftKey ||
|
|
618
|
-
// `altKey` is an old DOM API.
|
|
619
|
-
e.altKey ||
|
|
620
|
-
// `metaKey` is an old DOM API.
|
|
621
|
-
e.metaKey);
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* Determines and returns whether the given event has a target that already
|
|
625
|
-
* has event handlers attached because it is a native HTML control. Used to
|
|
626
|
-
* determine if preventDefault should be called when isActionKeyEvent is true.
|
|
627
|
-
* @param e The event.
|
|
628
|
-
* @return If preventDefault should be called.
|
|
629
|
-
*/
|
|
630
|
-
function shouldCallPreventDefaultOnNativeHtmlControl(e) {
|
|
631
|
-
const el = getTarget(e);
|
|
632
|
-
const tagName = el.tagName.toUpperCase();
|
|
633
|
-
const role = (el.getAttribute('role') || '').toUpperCase();
|
|
634
|
-
if (tagName === 'BUTTON' || role === 'BUTTON') {
|
|
635
|
-
return true;
|
|
636
|
-
}
|
|
637
|
-
if (!isNativeHTMLControl(el)) {
|
|
638
|
-
return false;
|
|
639
|
-
}
|
|
640
|
-
if (tagName === 'A') {
|
|
641
|
-
return false;
|
|
642
|
-
}
|
|
643
|
-
/**
|
|
644
|
-
* Fix for physical d-pads on feature phone platforms; the native event
|
|
645
|
-
* (ie. isTrusted: true) needs to fire to show the OPTION list. See
|
|
646
|
-
* b/135288469 for more info.
|
|
647
|
-
*/
|
|
648
|
-
if (tagName === 'SELECT') {
|
|
649
|
-
return false;
|
|
650
|
-
}
|
|
651
|
-
if (processSpace(el)) {
|
|
652
|
-
return false;
|
|
653
|
-
}
|
|
654
|
-
if (isTextControl(el)) {
|
|
655
|
-
return false;
|
|
656
|
-
}
|
|
657
|
-
return true;
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* Determines and returns whether the given event acts like a regular DOM click,
|
|
661
|
-
* and should be handled instead of the click. If this returns true, the caller
|
|
662
|
-
* will call preventDefault() to prevent a possible duplicate event.
|
|
663
|
-
* This is represented by a keypress (keydown on Gecko browsers) on Enter or
|
|
664
|
-
* Space key.
|
|
665
|
-
* @param e The event.
|
|
666
|
-
* @return True, if the event emulates a DOM click.
|
|
667
|
-
*/
|
|
668
|
-
function isActionKeyEvent(e) {
|
|
669
|
-
let key =
|
|
670
|
-
// `which` is an old DOM API.
|
|
671
|
-
e.which ||
|
|
672
|
-
// `keyCode` is an old DOM API.
|
|
673
|
-
e.keyCode;
|
|
674
|
-
if (!key && e.key) {
|
|
675
|
-
key = ACTION_KEY_TO_KEYCODE[e.key];
|
|
676
|
-
}
|
|
677
|
-
if (isWebKit && key === KeyCode.MAC_ENTER) {
|
|
678
|
-
key = KeyCode.ENTER;
|
|
679
|
-
}
|
|
680
|
-
if (key !== KeyCode.ENTER && key !== KeyCode.SPACE) {
|
|
681
|
-
return false;
|
|
682
|
-
}
|
|
683
|
-
const el = getTarget(e);
|
|
684
|
-
if (e.type !== EventType.KEYDOWN || !isValidActionKeyTarget(el) || hasModifierKey(e)) {
|
|
685
|
-
return false;
|
|
686
|
-
}
|
|
687
|
-
// For <input type="checkbox">, we must only handle the browser's native click
|
|
688
|
-
// event, so that the browser can toggle the checkbox.
|
|
689
|
-
if (processSpace(el) && key === KeyCode.SPACE) {
|
|
690
|
-
return false;
|
|
691
|
-
}
|
|
692
|
-
// If this element is non-focusable, ignore stray keystrokes (b/18337209)
|
|
693
|
-
// Sscreen readers can move without tab focus, so any tabIndex is focusable.
|
|
694
|
-
// See B/21809604
|
|
695
|
-
if (!isFocusable(el)) {
|
|
696
|
-
return false;
|
|
697
|
-
}
|
|
698
|
-
const type = (el.getAttribute('role') ||
|
|
699
|
-
el.type ||
|
|
700
|
-
el.tagName).toUpperCase();
|
|
701
|
-
const isSpecificTriggerKey = IDENTIFIER_TO_KEY_TRIGGER_MAPPING[type] % key === 0;
|
|
702
|
-
const isDefaultTriggerKey = !(type in IDENTIFIER_TO_KEY_TRIGGER_MAPPING) && key === KeyCode.ENTER;
|
|
703
|
-
const hasType = el.tagName.toUpperCase() !== 'INPUT' || !!el.type;
|
|
704
|
-
return (isSpecificTriggerKey || isDefaultTriggerKey) && hasType;
|
|
705
|
-
}
|
|
706
|
-
/**
|
|
707
|
-
* Checks whether a DOM element can receive keyboard focus.
|
|
708
|
-
* This code is based on goog.dom.isFocusable, but simplified since we shouldn't
|
|
709
|
-
* care about visibility if we're already handling a keyboard event.
|
|
710
|
-
*/
|
|
711
|
-
function isFocusable(el) {
|
|
712
|
-
return ((el.tagName in NATIVELY_FOCUSABLE_ELEMENTS || hasSpecifiedTabIndex(el)) &&
|
|
713
|
-
!el.disabled);
|
|
714
|
-
}
|
|
715
|
-
/**
|
|
716
|
-
* @param element Element to check.
|
|
717
|
-
* @return Whether the element has a specified tab index.
|
|
718
|
-
*/
|
|
719
|
-
function hasSpecifiedTabIndex(element) {
|
|
720
|
-
// IE returns 0 for an unset tabIndex, so we must use getAttributeNode(),
|
|
721
|
-
// which returns an object with a 'specified' property if tabIndex is
|
|
722
|
-
// specified. This works on other browsers, too.
|
|
723
|
-
const attrNode = element.getAttributeNode('tabindex'); // Must be lowercase!
|
|
724
|
-
return attrNode != null && attrNode.specified;
|
|
725
|
-
}
|
|
726
|
-
/** Element tagnames that are focusable by default. */
|
|
727
|
-
const NATIVELY_FOCUSABLE_ELEMENTS = {
|
|
728
|
-
'A': 1,
|
|
729
|
-
'INPUT': 1,
|
|
730
|
-
'TEXTAREA': 1,
|
|
731
|
-
'SELECT': 1,
|
|
732
|
-
'BUTTON': 1,
|
|
733
|
-
};
|
|
734
|
-
/** @return True, if the Space key was pressed. */
|
|
735
|
-
function isSpaceKeyEvent(e) {
|
|
736
|
-
const key =
|
|
737
|
-
// `which` is an old DOM API.
|
|
738
|
-
e.which ||
|
|
739
|
-
// `keyCode` is an old DOM API.
|
|
740
|
-
e.keyCode;
|
|
741
|
-
const el = getTarget(e);
|
|
742
|
-
const elementName = (el.type || el.tagName).toUpperCase();
|
|
743
|
-
return key === KeyCode.SPACE && elementName !== 'CHECKBOX';
|
|
744
|
-
}
|
|
745
443
|
/**
|
|
746
444
|
* Determines whether the event corresponds to a non-bubbling mouse
|
|
747
445
|
* event type (mouseenter, mouseleave, pointerenter, and pointerleave).
|
|
@@ -821,218 +519,6 @@ function createMouseSpecialEvent(e, target) {
|
|
|
821
519
|
copy['_originalEvent'] = e;
|
|
822
520
|
return copy;
|
|
823
521
|
}
|
|
824
|
-
/**
|
|
825
|
-
* Returns touch data extracted from the touch event: clientX, clientY, screenX
|
|
826
|
-
* and screenY. If the event has no touch information at all, the returned
|
|
827
|
-
* value is null.
|
|
828
|
-
*
|
|
829
|
-
* The fields of this Object are unquoted.
|
|
830
|
-
*
|
|
831
|
-
* @param event A touch event.
|
|
832
|
-
*/
|
|
833
|
-
function getTouchData(event) {
|
|
834
|
-
const touch = (event.changedTouches && event.changedTouches[0]) || (event.touches && event.touches[0]);
|
|
835
|
-
if (!touch) {
|
|
836
|
-
return null;
|
|
837
|
-
}
|
|
838
|
-
return {
|
|
839
|
-
clientX: touch.clientX,
|
|
840
|
-
clientY: touch.clientY,
|
|
841
|
-
screenX: touch.screenX,
|
|
842
|
-
screenY: touch.screenY,
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
/**
|
|
846
|
-
* Creates a new EventLike object for a "click" event that's derived from the
|
|
847
|
-
* original corresponding "touchend" event for a fast-click implementation.
|
|
848
|
-
*
|
|
849
|
-
* It takes a touch event, adds common fields found in a click event and
|
|
850
|
-
* changes the type to 'click', so that the resulting event looks more like
|
|
851
|
-
* a real click event.
|
|
852
|
-
*
|
|
853
|
-
* @param event A touch event.
|
|
854
|
-
* @return A modified event-like object copied from the event object passed into
|
|
855
|
-
* this function.
|
|
856
|
-
*/
|
|
857
|
-
function recreateTouchEventAsClick(event) {
|
|
858
|
-
const click = {};
|
|
859
|
-
click['originalEventType'] = event.type;
|
|
860
|
-
click['type'] = EventType.CLICK;
|
|
861
|
-
for (const property in event) {
|
|
862
|
-
if (property === 'type' || property === 'srcElement') {
|
|
863
|
-
continue;
|
|
864
|
-
}
|
|
865
|
-
const key = property;
|
|
866
|
-
// Making a copy requires iterating through all properties of `TouchEvent`.
|
|
867
|
-
const value = event[key];
|
|
868
|
-
if (typeof value === 'function') {
|
|
869
|
-
continue;
|
|
870
|
-
}
|
|
871
|
-
// Value should be the expected type, but the value of `key` is not known
|
|
872
|
-
// statically.
|
|
873
|
-
click[key] = value;
|
|
874
|
-
}
|
|
875
|
-
// Ensure that the event has the most recent timestamp. This timestamp
|
|
876
|
-
// may be used in the future to validate or cancel subsequent click events.
|
|
877
|
-
click['timeStamp'] = Date.now();
|
|
878
|
-
// Emulate preventDefault and stopPropagation behavior
|
|
879
|
-
click['defaultPrevented'] = false;
|
|
880
|
-
click['preventDefault'] = syntheticPreventDefault;
|
|
881
|
-
click['_propagationStopped'] = false;
|
|
882
|
-
click['stopPropagation'] = syntheticStopPropagation;
|
|
883
|
-
// Emulate click coordinates using touch info
|
|
884
|
-
const touch = getTouchData(event);
|
|
885
|
-
if (touch) {
|
|
886
|
-
click['clientX'] = touch.clientX;
|
|
887
|
-
click['clientY'] = touch.clientY;
|
|
888
|
-
click['screenX'] = touch.screenX;
|
|
889
|
-
click['screenY'] = touch.screenY;
|
|
890
|
-
}
|
|
891
|
-
return click;
|
|
892
|
-
}
|
|
893
|
-
/**
|
|
894
|
-
* An implementation of "preventDefault" for a synthesized event. Simply
|
|
895
|
-
* sets "defaultPrevented" property to true.
|
|
896
|
-
*/
|
|
897
|
-
function syntheticPreventDefault() {
|
|
898
|
-
this.defaultPrevented = true;
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* An implementation of "stopPropagation" for a synthesized event. It simply
|
|
902
|
-
* sets a synthetic non-standard "_propagationStopped" property to true.
|
|
903
|
-
*/
|
|
904
|
-
function syntheticStopPropagation() {
|
|
905
|
-
this._propagationStopped = true;
|
|
906
|
-
}
|
|
907
|
-
/**
|
|
908
|
-
* Mapping of KeyboardEvent.key values to
|
|
909
|
-
* KeyCode values.
|
|
910
|
-
*/
|
|
911
|
-
const ACTION_KEY_TO_KEYCODE = {
|
|
912
|
-
'Enter': KeyCode.ENTER,
|
|
913
|
-
' ': KeyCode.SPACE,
|
|
914
|
-
};
|
|
915
|
-
/**
|
|
916
|
-
* Mapping of HTML element identifiers (ARIA role, type, or tagName) to the
|
|
917
|
-
* keys (enter and/or space) that should activate them. A value of zero means
|
|
918
|
-
* that both should activate them.
|
|
919
|
-
*/
|
|
920
|
-
const IDENTIFIER_TO_KEY_TRIGGER_MAPPING = {
|
|
921
|
-
'A': KeyCode.ENTER,
|
|
922
|
-
'BUTTON': 0,
|
|
923
|
-
'CHECKBOX': KeyCode.SPACE,
|
|
924
|
-
'COMBOBOX': KeyCode.ENTER,
|
|
925
|
-
'FILE': 0,
|
|
926
|
-
'GRIDCELL': KeyCode.ENTER,
|
|
927
|
-
'LINK': KeyCode.ENTER,
|
|
928
|
-
'LISTBOX': KeyCode.ENTER,
|
|
929
|
-
'MENU': 0,
|
|
930
|
-
'MENUBAR': 0,
|
|
931
|
-
'MENUITEM': 0,
|
|
932
|
-
'MENUITEMCHECKBOX': 0,
|
|
933
|
-
'MENUITEMRADIO': 0,
|
|
934
|
-
'OPTION': 0,
|
|
935
|
-
'RADIO': KeyCode.SPACE,
|
|
936
|
-
'RADIOGROUP': KeyCode.SPACE,
|
|
937
|
-
'RESET': 0,
|
|
938
|
-
'SUBMIT': 0,
|
|
939
|
-
'SWITCH': KeyCode.SPACE,
|
|
940
|
-
'TAB': 0,
|
|
941
|
-
'TREE': KeyCode.ENTER,
|
|
942
|
-
'TREEITEM': KeyCode.ENTER,
|
|
943
|
-
};
|
|
944
|
-
/**
|
|
945
|
-
* Returns whether or not to process space based on the type of the element;
|
|
946
|
-
* checks to make sure that type is not null.
|
|
947
|
-
* @param element The element.
|
|
948
|
-
* @return Whether or not to process space based on type.
|
|
949
|
-
*/
|
|
950
|
-
function processSpace(element) {
|
|
951
|
-
const type = (element.getAttribute('type') || element.tagName).toUpperCase();
|
|
952
|
-
return type in PROCESS_SPACE;
|
|
953
|
-
}
|
|
954
|
-
/**
|
|
955
|
-
* Returns whether or not the given element is a text control.
|
|
956
|
-
* @param el The element.
|
|
957
|
-
* @return Whether or not the given element is a text control.
|
|
958
|
-
*/
|
|
959
|
-
function isTextControl(el) {
|
|
960
|
-
const type = (el.getAttribute('type') || el.tagName).toUpperCase();
|
|
961
|
-
return type in TEXT_CONTROLS;
|
|
962
|
-
}
|
|
963
|
-
/**
|
|
964
|
-
* Returns if the given element is a native HTML control.
|
|
965
|
-
* @param el The element.
|
|
966
|
-
* @return If the given element is a native HTML control.
|
|
967
|
-
*/
|
|
968
|
-
function isNativeHTMLControl(el) {
|
|
969
|
-
return el.tagName.toUpperCase() in NATIVE_HTML_CONTROLS;
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
|
-
* Returns if the given element is natively activatable. Browsers emit click
|
|
973
|
-
* events for natively activatable elements, even when activated via keyboard.
|
|
974
|
-
* For these elements, we don't need to raise a11y click events.
|
|
975
|
-
* @param el The element.
|
|
976
|
-
* @return If the given element is a native HTML control.
|
|
977
|
-
*/
|
|
978
|
-
function isNativelyActivatable(el) {
|
|
979
|
-
return (el.tagName.toUpperCase() === 'BUTTON' ||
|
|
980
|
-
(!!el.type && el.type.toUpperCase() === 'FILE'));
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
|
-
* HTML <input> types (not ARIA roles) which will auto-trigger a click event for
|
|
984
|
-
* the Space key, with side-effects. We will not call preventDefault if space is
|
|
985
|
-
* pressed, nor will we raise a11y click events. For all other elements, we can
|
|
986
|
-
* suppress the default event (which has no desired side-effects) and handle the
|
|
987
|
-
* keydown ourselves.
|
|
988
|
-
*/
|
|
989
|
-
const PROCESS_SPACE = {
|
|
990
|
-
'CHECKBOX': true,
|
|
991
|
-
'FILE': true,
|
|
992
|
-
'OPTION': true,
|
|
993
|
-
'RADIO': true,
|
|
994
|
-
};
|
|
995
|
-
/** TagNames and Input types for which to not process enter/space as click. */
|
|
996
|
-
const TEXT_CONTROLS = {
|
|
997
|
-
'COLOR': true,
|
|
998
|
-
'DATE': true,
|
|
999
|
-
'DATETIME': true,
|
|
1000
|
-
'DATETIME-LOCAL': true,
|
|
1001
|
-
'EMAIL': true,
|
|
1002
|
-
'MONTH': true,
|
|
1003
|
-
'NUMBER': true,
|
|
1004
|
-
'PASSWORD': true,
|
|
1005
|
-
'RANGE': true,
|
|
1006
|
-
'SEARCH': true,
|
|
1007
|
-
'TEL': true,
|
|
1008
|
-
'TEXT': true,
|
|
1009
|
-
'TEXTAREA': true,
|
|
1010
|
-
'TIME': true,
|
|
1011
|
-
'URL': true,
|
|
1012
|
-
'WEEK': true,
|
|
1013
|
-
};
|
|
1014
|
-
/** TagNames that are native HTML controls. */
|
|
1015
|
-
const NATIVE_HTML_CONTROLS = {
|
|
1016
|
-
'A': true,
|
|
1017
|
-
'AREA': true,
|
|
1018
|
-
'BUTTON': true,
|
|
1019
|
-
'DIALOG': true,
|
|
1020
|
-
'IMG': true,
|
|
1021
|
-
'INPUT': true,
|
|
1022
|
-
'LINK': true,
|
|
1023
|
-
'MENU': true,
|
|
1024
|
-
'OPTGROUP': true,
|
|
1025
|
-
'OPTION': true,
|
|
1026
|
-
'PROGRESS': true,
|
|
1027
|
-
'SELECT': true,
|
|
1028
|
-
'TEXTAREA': true,
|
|
1029
|
-
};
|
|
1030
|
-
/** Exported for testing. */
|
|
1031
|
-
const testing = {
|
|
1032
|
-
setIsMac(value) {
|
|
1033
|
-
isMac = value;
|
|
1034
|
-
},
|
|
1035
|
-
};
|
|
1036
522
|
|
|
1037
523
|
/**
|
|
1038
524
|
* Whether the user agent is running on iOS.
|
|
@@ -1091,11 +577,6 @@ class EventContractContainer {
|
|
|
1091
577
|
}
|
|
1092
578
|
|
|
1093
579
|
const Char = {
|
|
1094
|
-
/**
|
|
1095
|
-
* The separator between the namespace and the action name in the
|
|
1096
|
-
* jsaction attribute value.
|
|
1097
|
-
*/
|
|
1098
|
-
NAMESPACE_ACTION_SEPARATOR: '.',
|
|
1099
580
|
/**
|
|
1100
581
|
* The separator between the event name and action in the jsaction
|
|
1101
582
|
* attribute value.
|
|
@@ -1156,10 +637,6 @@ function unsetAction(eventInfo) {
|
|
|
1156
637
|
eventInfo.eia = undefined;
|
|
1157
638
|
}
|
|
1158
639
|
/** Added for readability when accessing stable property names. */
|
|
1159
|
-
function getActionName(actionInfo) {
|
|
1160
|
-
return actionInfo[0];
|
|
1161
|
-
}
|
|
1162
|
-
/** Added for readability when accessing stable property names. */
|
|
1163
640
|
function getActionElement(actionInfo) {
|
|
1164
641
|
return actionInfo[1];
|
|
1165
642
|
}
|
|
@@ -1172,14 +649,6 @@ function setIsReplay(eventInfo, replay) {
|
|
|
1172
649
|
eventInfo.eirp = replay;
|
|
1173
650
|
}
|
|
1174
651
|
/** Added for readability when accessing stable property names. */
|
|
1175
|
-
function getA11yClickKey(eventInfo) {
|
|
1176
|
-
return eventInfo.eiack;
|
|
1177
|
-
}
|
|
1178
|
-
/** Added for readability when accessing stable property names. */
|
|
1179
|
-
function setA11yClickKey(eventInfo, a11yClickKey) {
|
|
1180
|
-
eventInfo.eiack = a11yClickKey;
|
|
1181
|
-
}
|
|
1182
|
-
/** Added for readability when accessing stable property names. */
|
|
1183
652
|
function getResolved(eventInfo) {
|
|
1184
653
|
return eventInfo.eir;
|
|
1185
654
|
}
|
|
@@ -1219,24 +688,6 @@ function createEventInfoFromParameters(eventType, event, targetElement, containe
|
|
|
1219
688
|
eiack: a11yClickKey,
|
|
1220
689
|
};
|
|
1221
690
|
}
|
|
1222
|
-
/**
|
|
1223
|
-
* Utility function for creating an `EventInfo`.
|
|
1224
|
-
*
|
|
1225
|
-
* This should be used in compilation units that are less sensitive to code
|
|
1226
|
-
* size.
|
|
1227
|
-
*/
|
|
1228
|
-
function createEventInfo({ eventType, event, targetElement, container, timestamp, action, isReplay, a11yClickKey, }) {
|
|
1229
|
-
return {
|
|
1230
|
-
eventType,
|
|
1231
|
-
event,
|
|
1232
|
-
targetElement,
|
|
1233
|
-
eic: container,
|
|
1234
|
-
timeStamp: timestamp,
|
|
1235
|
-
eia: action ? [action.name, action.element] : undefined,
|
|
1236
|
-
eirp: isReplay,
|
|
1237
|
-
eiack: a11yClickKey,
|
|
1238
|
-
};
|
|
1239
|
-
}
|
|
1240
691
|
/**
|
|
1241
692
|
* Utility class around an `EventInfo`.
|
|
1242
693
|
*
|
|
@@ -1628,17 +1079,6 @@ class Dispatcher {
|
|
|
1628
1079
|
});
|
|
1629
1080
|
}
|
|
1630
1081
|
}
|
|
1631
|
-
/**
|
|
1632
|
-
* Creates an `EventReplayer` that calls the `replay` function for every `eventInfoWrapper` in
|
|
1633
|
-
* the queue.
|
|
1634
|
-
*/
|
|
1635
|
-
function createEventReplayer(replay) {
|
|
1636
|
-
return (eventInfoWrappers) => {
|
|
1637
|
-
for (const eventInfoWrapper of eventInfoWrappers) {
|
|
1638
|
-
replay(eventInfoWrapper);
|
|
1639
|
-
}
|
|
1640
|
-
};
|
|
1641
|
-
}
|
|
1642
1082
|
/**
|
|
1643
1083
|
* Returns true if the default action of this event should be prevented before
|
|
1644
1084
|
* this event is dispatched.
|
|
@@ -1652,15 +1092,6 @@ function shouldPreventDefaultBeforeDispatching(actionElement, eventInfoWrapper)
|
|
|
1652
1092
|
(eventInfoWrapper.getEventType() === EventType.CLICK ||
|
|
1653
1093
|
eventInfoWrapper.getEventType() === EventType.CLICKMOD));
|
|
1654
1094
|
}
|
|
1655
|
-
/**
|
|
1656
|
-
* Registers deferred functionality for an EventContract and a Jsaction
|
|
1657
|
-
* Dispatcher.
|
|
1658
|
-
*/
|
|
1659
|
-
function registerDispatcher$2(eventContract, dispatcher) {
|
|
1660
|
-
eventContract.ecrd((eventInfo) => {
|
|
1661
|
-
dispatcher.dispatch(eventInfo);
|
|
1662
|
-
}, Restriction.I_AM_THE_JSACTION_FRAMEWORK);
|
|
1663
|
-
}
|
|
1664
1095
|
|
|
1665
1096
|
/** An internal symbol used to indicate whether propagation should be stopped or not. */
|
|
1666
1097
|
const PROPAGATION_STOPPED_SYMBOL = Symbol.for('propagationStopped');
|
|
@@ -1794,24 +1225,6 @@ function registerDispatcher$1(eventContract, dispatcher) {
|
|
|
1794
1225
|
}, Restriction.I_AM_THE_JSACTION_FRAMEWORK);
|
|
1795
1226
|
}
|
|
1796
1227
|
|
|
1797
|
-
/**
|
|
1798
|
-
* EarlyEventContract intercepts events in the bubbling phase at the
|
|
1799
|
-
* boundary of the document body. This mapping will be passed to the
|
|
1800
|
-
* late-loaded EventContract.
|
|
1801
|
-
*/
|
|
1802
|
-
class EarlyEventContract {
|
|
1803
|
-
dataContainer;
|
|
1804
|
-
constructor(dataContainer = window, container = window.document.documentElement) {
|
|
1805
|
-
this.dataContainer = dataContainer;
|
|
1806
|
-
dataContainer._ejsa = createEarlyJsactionData(container);
|
|
1807
|
-
}
|
|
1808
|
-
/**
|
|
1809
|
-
* Installs a list of event types for container .
|
|
1810
|
-
*/
|
|
1811
|
-
addEvents(types, capture) {
|
|
1812
|
-
addEvents(this.dataContainer._ejsa, types, capture);
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
1228
|
/** Creates an `EarlyJsactionData` object. */
|
|
1816
1229
|
function createEarlyJsactionData(container) {
|
|
1817
1230
|
const q = [];
|