@angular/core 18.2.0-next.0 → 18.2.0-next.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.
- package/esm2022/primitives/event-dispatch/contract_binary.mjs +3 -3
- package/esm2022/primitives/event-dispatch/index.mjs +6 -7
- package/esm2022/primitives/event-dispatch/src/a11y_click.mjs +1 -1
- package/esm2022/primitives/event-dispatch/src/action_resolver.mjs +1 -1
- package/esm2022/primitives/event-dispatch/src/bootstrap_app_scoped.mjs +29 -0
- package/esm2022/primitives/event-dispatch/src/bootstrap_global.mjs +21 -0
- package/esm2022/primitives/event-dispatch/src/cache.mjs +10 -21
- package/esm2022/primitives/event-dispatch/src/earlyeventcontract.mjs +32 -21
- package/esm2022/primitives/event-dispatch/src/event.mjs +3 -3
- package/esm2022/primitives/event-dispatch/src/event_contract_defines.mjs +1 -6
- package/esm2022/primitives/event-dispatch/src/event_type.mjs +19 -21
- package/esm2022/primitives/event-dispatch/src/eventcontract.mjs +6 -8
- package/esm2022/primitives/event-dispatch/src/property.mjs +1 -1
- package/esm2022/src/event_delegation_utils.mjs +10 -10
- package/esm2022/src/hydration/event_replay.mjs +17 -22
- package/esm2022/src/render3/after_render_hooks.mjs +7 -2
- package/esm2022/src/render3/component_ref.mjs +1 -1
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/testing/src/logger.mjs +3 -3
- package/event-dispatch-contract.min.js +1 -1
- package/fesm2022/core.mjs +33 -33
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +452 -529
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +1 -1
- package/index.d.ts +4 -4
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +23 -37
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/migrations/invalid-two-way-bindings/bundle.js +40 -31
- package/schematics/migrations/invalid-two-way-bindings/bundle.js.map +2 -2
- package/schematics/ng-generate/control-flow-migration/bundle.js +47 -31
- package/schematics/ng-generate/control-flow-migration/bundle.js.map +2 -2
- package/schematics/ng-generate/standalone-migration/bundle.js +611 -65
- package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
- package/testing/index.d.ts +1 -1
- package/esm2022/primitives/event-dispatch/src/register_events.mjs +0 -31
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v18.2.0-next.
|
|
2
|
+
* @license Angular v18.2.0-next.1
|
|
3
3
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -20,19 +20,80 @@ const Attribute = {
|
|
|
20
20
|
JSACTION: 'jsaction',
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
/** All properties that are used by jsaction. */
|
|
24
|
+
const Property = {
|
|
24
25
|
/**
|
|
25
|
-
* The
|
|
26
|
-
*
|
|
26
|
+
* The parsed value of the jsaction attribute is stored in this
|
|
27
|
+
* property on the DOM node. The parsed value is an Object. The
|
|
28
|
+
* property names of the object are the events; the values are the
|
|
29
|
+
* names of the actions. This property is attached even on nodes
|
|
30
|
+
* that don't have a jsaction attribute as an optimization, because
|
|
31
|
+
* property lookup is faster than attribute access.
|
|
27
32
|
*/
|
|
28
|
-
|
|
33
|
+
JSACTION: '__jsaction',
|
|
29
34
|
/**
|
|
30
|
-
* The
|
|
31
|
-
*
|
|
35
|
+
* The owner property references an a logical owner for a DOM node. JSAction
|
|
36
|
+
* will follow this reference instead of parentNode when traversing the DOM
|
|
37
|
+
* to find jsaction attributes. This allows overlaying a logical structure
|
|
38
|
+
* over a document where the DOM structure can't reflect that structure.
|
|
32
39
|
*/
|
|
33
|
-
|
|
40
|
+
OWNER: '__owner',
|
|
34
41
|
};
|
|
35
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Map from jsaction annotation to a parsed map from event name to action name.
|
|
45
|
+
*/
|
|
46
|
+
const parseCache = {};
|
|
47
|
+
/**
|
|
48
|
+
* Reads the jsaction parser cache from the given DOM Element.
|
|
49
|
+
*/
|
|
50
|
+
function get(element) {
|
|
51
|
+
return element[Property.JSACTION];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Reads the jsaction parser cache for the given DOM element. If no cache is yet present,
|
|
55
|
+
* creates an empty one.
|
|
56
|
+
*/
|
|
57
|
+
function getDefaulted(element) {
|
|
58
|
+
const cache = get(element) ?? {};
|
|
59
|
+
set(element, cache);
|
|
60
|
+
return cache;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Writes the jsaction parser cache to the given DOM Element.
|
|
64
|
+
*/
|
|
65
|
+
function set(element, actionMap) {
|
|
66
|
+
element[Property.JSACTION] = actionMap;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Looks up the parsed action map from the source jsaction attribute value.
|
|
70
|
+
*
|
|
71
|
+
* @param text Unparsed jsaction attribute value.
|
|
72
|
+
* @return Parsed jsaction attribute value, if already present in the cache.
|
|
73
|
+
*/
|
|
74
|
+
function getParsed(text) {
|
|
75
|
+
return parseCache[text];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Inserts the parse result for the given source jsaction value into the cache.
|
|
79
|
+
*
|
|
80
|
+
* @param text Unparsed jsaction attribute value.
|
|
81
|
+
* @param parsed Attribute value parsed into the action map.
|
|
82
|
+
*/
|
|
83
|
+
function setParsed(text, parsed) {
|
|
84
|
+
parseCache[text] = parsed;
|
|
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
|
+
|
|
36
97
|
/*
|
|
37
98
|
* Names of events that are special to jsaction. These are not all
|
|
38
99
|
* event types that are legal to use in either HTML or the addEvent()
|
|
@@ -269,32 +330,25 @@ const EventType = {
|
|
|
269
330
|
*/
|
|
270
331
|
CUSTOM: '_custom',
|
|
271
332
|
};
|
|
272
|
-
|
|
333
|
+
/** All event types that do not bubble or capture and need a polyfill. */
|
|
334
|
+
const MOUSE_SPECIAL_EVENT_TYPES = [
|
|
273
335
|
EventType.MOUSEENTER,
|
|
274
336
|
EventType.MOUSELEAVE,
|
|
275
337
|
'pointerenter',
|
|
276
338
|
'pointerleave',
|
|
277
339
|
];
|
|
278
|
-
/**
|
|
279
|
-
|
|
280
|
-
*/
|
|
281
|
-
const isSupportedEvent = (eventType) => SUPPORTED_EVENTS.indexOf(eventType) >= 0;
|
|
282
|
-
const SUPPORTED_EVENTS = [
|
|
340
|
+
/** All event types that are registered in the bubble phase. */
|
|
341
|
+
const BUBBLE_EVENT_TYPES = [
|
|
283
342
|
EventType.CLICK,
|
|
284
343
|
EventType.DBLCLICK,
|
|
285
|
-
EventType.FOCUS,
|
|
286
344
|
EventType.FOCUSIN,
|
|
287
|
-
EventType.BLUR,
|
|
288
|
-
EventType.ERROR,
|
|
289
345
|
EventType.FOCUSOUT,
|
|
290
346
|
EventType.KEYDOWN,
|
|
291
347
|
EventType.KEYUP,
|
|
292
348
|
EventType.KEYPRESS,
|
|
293
|
-
EventType.LOAD,
|
|
294
349
|
EventType.MOUSEOVER,
|
|
295
350
|
EventType.MOUSEOUT,
|
|
296
351
|
EventType.SUBMIT,
|
|
297
|
-
EventType.TOGGLE,
|
|
298
352
|
EventType.TOUCHSTART,
|
|
299
353
|
EventType.TOUCHEND,
|
|
300
354
|
EventType.TOUCHMOVE,
|
|
@@ -332,319 +386,32 @@ const SUPPORTED_EVENTS = [
|
|
|
332
386
|
'ended',
|
|
333
387
|
'loadedmetadata',
|
|
334
388
|
// Page visibility events.
|
|
335
|
-
'pagehide',
|
|
336
|
-
'pageshow',
|
|
337
|
-
'visibilitychange',
|
|
338
|
-
// Content visibility events.
|
|
339
|
-
'beforematch',
|
|
340
|
-
];
|
|
341
|
-
/**
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
* property on the DOM node. The parsed value is an Object. The
|
|
362
|
-
* property names of the object are the events; the values are the
|
|
363
|
-
* names of the actions. This property is attached even on nodes
|
|
364
|
-
* that don't have a jsaction attribute as an optimization, because
|
|
365
|
-
* property lookup is faster than attribute access.
|
|
366
|
-
*/
|
|
367
|
-
JSACTION: '__jsaction',
|
|
368
|
-
/**
|
|
369
|
-
* The owner property references an a logical owner for a DOM node. JSAction
|
|
370
|
-
* will follow this reference instead of parentNode when traversing the DOM
|
|
371
|
-
* to find jsaction attributes. This allows overlaying a logical structure
|
|
372
|
-
* over a document where the DOM structure can't reflect that structure.
|
|
373
|
-
*/
|
|
374
|
-
OWNER: '__owner',
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Map from jsaction annotation to a parsed map from event name to action name.
|
|
379
|
-
*/
|
|
380
|
-
const parseCache = {};
|
|
381
|
-
function registerEventType(element, eventType, action) {
|
|
382
|
-
const cache = get(element) || {};
|
|
383
|
-
cache[eventType] = action;
|
|
384
|
-
set(element, cache);
|
|
385
|
-
}
|
|
386
|
-
function unregisterEventType(element, eventType) {
|
|
387
|
-
const cache = get(element);
|
|
388
|
-
if (cache) {
|
|
389
|
-
cache[eventType] = undefined;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Reads the jsaction parser cache from the given DOM Element.
|
|
394
|
-
*
|
|
395
|
-
* @param element .
|
|
396
|
-
* @return Map from event to qualified name of the jsaction bound to it.
|
|
397
|
-
*/
|
|
398
|
-
function get(element) {
|
|
399
|
-
// @ts-ignore
|
|
400
|
-
return element[Property.JSACTION];
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* Writes the jsaction parser cache to the given DOM Element.
|
|
404
|
-
*
|
|
405
|
-
* @param element .
|
|
406
|
-
* @param actionMap Map from event to qualified name of the jsaction bound to
|
|
407
|
-
* it.
|
|
408
|
-
*/
|
|
409
|
-
function set(element, actionMap) {
|
|
410
|
-
// @ts-ignore
|
|
411
|
-
element[Property.JSACTION] = actionMap;
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Looks up the parsed action map from the source jsaction attribute value.
|
|
415
|
-
*
|
|
416
|
-
* @param text Unparsed jsaction attribute value.
|
|
417
|
-
* @return Parsed jsaction attribute value, if already present in the cache.
|
|
418
|
-
*/
|
|
419
|
-
function getParsed(text) {
|
|
420
|
-
return parseCache[text];
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Inserts the parse result for the given source jsaction value into the cache.
|
|
424
|
-
*
|
|
425
|
-
* @param text Unparsed jsaction attribute value.
|
|
426
|
-
* @param parsed Attribute value parsed into the action map.
|
|
427
|
-
*/
|
|
428
|
-
function setParsed(text, parsed) {
|
|
429
|
-
parseCache[text] = parsed;
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* Clears the jsaction parser cache from the given DOM Element.
|
|
433
|
-
*
|
|
434
|
-
* @param element .
|
|
435
|
-
*/
|
|
436
|
-
function clear(element) {
|
|
437
|
-
if (Property.JSACTION in element) {
|
|
438
|
-
delete element[Property.JSACTION];
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/** Added for readability when accessing stable property names. */
|
|
443
|
-
function getEventType(eventInfo) {
|
|
444
|
-
return eventInfo.eventType;
|
|
445
|
-
}
|
|
446
|
-
/** Added for readability when accessing stable property names. */
|
|
447
|
-
function setEventType(eventInfo, eventType) {
|
|
448
|
-
eventInfo.eventType = eventType;
|
|
449
|
-
}
|
|
450
|
-
/** Added for readability when accessing stable property names. */
|
|
451
|
-
function getEvent(eventInfo) {
|
|
452
|
-
return eventInfo.event;
|
|
453
|
-
}
|
|
454
|
-
/** Added for readability when accessing stable property names. */
|
|
455
|
-
function setEvent(eventInfo, event) {
|
|
456
|
-
eventInfo.event = event;
|
|
457
|
-
}
|
|
458
|
-
/** Added for readability when accessing stable property names. */
|
|
459
|
-
function getTargetElement(eventInfo) {
|
|
460
|
-
return eventInfo.targetElement;
|
|
461
|
-
}
|
|
462
|
-
/** Added for readability when accessing stable property names. */
|
|
463
|
-
function setTargetElement(eventInfo, targetElement) {
|
|
464
|
-
eventInfo.targetElement = targetElement;
|
|
465
|
-
}
|
|
466
|
-
/** Added for readability when accessing stable property names. */
|
|
467
|
-
function getContainer(eventInfo) {
|
|
468
|
-
return eventInfo.eic;
|
|
469
|
-
}
|
|
470
|
-
/** Added for readability when accessing stable property names. */
|
|
471
|
-
function setContainer(eventInfo, container) {
|
|
472
|
-
eventInfo.eic = container;
|
|
473
|
-
}
|
|
474
|
-
/** Added for readability when accessing stable property names. */
|
|
475
|
-
function getTimestamp(eventInfo) {
|
|
476
|
-
return eventInfo.timeStamp;
|
|
477
|
-
}
|
|
478
|
-
/** Added for readability when accessing stable property names. */
|
|
479
|
-
function setTimestamp(eventInfo, timestamp) {
|
|
480
|
-
eventInfo.timeStamp = timestamp;
|
|
481
|
-
}
|
|
482
|
-
/** Added for readability when accessing stable property names. */
|
|
483
|
-
function getAction(eventInfo) {
|
|
484
|
-
return eventInfo.eia;
|
|
485
|
-
}
|
|
486
|
-
/** Added for readability when accessing stable property names. */
|
|
487
|
-
function setAction(eventInfo, actionName, actionElement) {
|
|
488
|
-
eventInfo.eia = [actionName, actionElement];
|
|
489
|
-
}
|
|
490
|
-
/** Added for readability when accessing stable property names. */
|
|
491
|
-
function unsetAction(eventInfo) {
|
|
492
|
-
eventInfo.eia = undefined;
|
|
493
|
-
}
|
|
494
|
-
/** Added for readability when accessing stable property names. */
|
|
495
|
-
function getActionName(actionInfo) {
|
|
496
|
-
return actionInfo[0];
|
|
497
|
-
}
|
|
498
|
-
/** Added for readability when accessing stable property names. */
|
|
499
|
-
function getActionElement(actionInfo) {
|
|
500
|
-
return actionInfo[1];
|
|
501
|
-
}
|
|
502
|
-
/** Added for readability when accessing stable property names. */
|
|
503
|
-
function getIsReplay(eventInfo) {
|
|
504
|
-
return eventInfo.eirp;
|
|
505
|
-
}
|
|
506
|
-
/** Added for readability when accessing stable property names. */
|
|
507
|
-
function setIsReplay(eventInfo, replay) {
|
|
508
|
-
eventInfo.eirp = replay;
|
|
509
|
-
}
|
|
510
|
-
/** Added for readability when accessing stable property names. */
|
|
511
|
-
function getA11yClickKey(eventInfo) {
|
|
512
|
-
return eventInfo.eiack;
|
|
513
|
-
}
|
|
514
|
-
/** Added for readability when accessing stable property names. */
|
|
515
|
-
function setA11yClickKey(eventInfo, a11yClickKey) {
|
|
516
|
-
eventInfo.eiack = a11yClickKey;
|
|
517
|
-
}
|
|
518
|
-
/** Added for readability when accessing stable property names. */
|
|
519
|
-
function getResolved(eventInfo) {
|
|
520
|
-
return eventInfo.eir;
|
|
521
|
-
}
|
|
522
|
-
/** Added for readability when accessing stable property names. */
|
|
523
|
-
function setResolved(eventInfo, resolved) {
|
|
524
|
-
eventInfo.eir = resolved;
|
|
525
|
-
}
|
|
526
|
-
/** Clones an `EventInfo` */
|
|
527
|
-
function cloneEventInfo(eventInfo) {
|
|
528
|
-
return {
|
|
529
|
-
eventType: eventInfo.eventType,
|
|
530
|
-
event: eventInfo.event,
|
|
531
|
-
targetElement: eventInfo.targetElement,
|
|
532
|
-
eic: eventInfo.eic,
|
|
533
|
-
eia: eventInfo.eia,
|
|
534
|
-
timeStamp: eventInfo.timeStamp,
|
|
535
|
-
eirp: eventInfo.eirp,
|
|
536
|
-
eiack: eventInfo.eiack,
|
|
537
|
-
eir: eventInfo.eir,
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Utility function for creating an `EventInfo`.
|
|
542
|
-
*
|
|
543
|
-
* This can be used from code-size sensitive compilation units, as taking
|
|
544
|
-
* parameters vs. an `Object` literal reduces code size.
|
|
545
|
-
*/
|
|
546
|
-
function createEventInfoFromParameters(eventType, event, targetElement, container, timestamp, action, isReplay, a11yClickKey) {
|
|
547
|
-
return {
|
|
548
|
-
eventType,
|
|
549
|
-
event,
|
|
550
|
-
targetElement,
|
|
551
|
-
eic: container,
|
|
552
|
-
timeStamp: timestamp,
|
|
553
|
-
eia: action,
|
|
554
|
-
eirp: isReplay,
|
|
555
|
-
eiack: a11yClickKey,
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
/**
|
|
559
|
-
* Utility function for creating an `EventInfo`.
|
|
560
|
-
*
|
|
561
|
-
* This should be used in compilation units that are less sensitive to code
|
|
562
|
-
* size.
|
|
563
|
-
*/
|
|
564
|
-
function createEventInfo({ eventType, event, targetElement, container, timestamp, action, isReplay, a11yClickKey, }) {
|
|
565
|
-
return {
|
|
566
|
-
eventType,
|
|
567
|
-
event,
|
|
568
|
-
targetElement,
|
|
569
|
-
eic: container,
|
|
570
|
-
timeStamp: timestamp,
|
|
571
|
-
eia: action ? [action.name, action.element] : undefined,
|
|
572
|
-
eirp: isReplay,
|
|
573
|
-
eiack: a11yClickKey,
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
/**
|
|
577
|
-
* Utility class around an `EventInfo`.
|
|
578
|
-
*
|
|
579
|
-
* This should be used in compilation units that are less sensitive to code
|
|
580
|
-
* size.
|
|
581
|
-
*/
|
|
582
|
-
class EventInfoWrapper {
|
|
583
|
-
constructor(eventInfo) {
|
|
584
|
-
this.eventInfo = eventInfo;
|
|
585
|
-
}
|
|
586
|
-
getEventType() {
|
|
587
|
-
return getEventType(this.eventInfo);
|
|
588
|
-
}
|
|
589
|
-
setEventType(eventType) {
|
|
590
|
-
setEventType(this.eventInfo, eventType);
|
|
591
|
-
}
|
|
592
|
-
getEvent() {
|
|
593
|
-
return getEvent(this.eventInfo);
|
|
594
|
-
}
|
|
595
|
-
setEvent(event) {
|
|
596
|
-
setEvent(this.eventInfo, event);
|
|
597
|
-
}
|
|
598
|
-
getTargetElement() {
|
|
599
|
-
return getTargetElement(this.eventInfo);
|
|
600
|
-
}
|
|
601
|
-
setTargetElement(targetElement) {
|
|
602
|
-
setTargetElement(this.eventInfo, targetElement);
|
|
603
|
-
}
|
|
604
|
-
getContainer() {
|
|
605
|
-
return getContainer(this.eventInfo);
|
|
606
|
-
}
|
|
607
|
-
setContainer(container) {
|
|
608
|
-
setContainer(this.eventInfo, container);
|
|
609
|
-
}
|
|
610
|
-
getTimestamp() {
|
|
611
|
-
return getTimestamp(this.eventInfo);
|
|
612
|
-
}
|
|
613
|
-
setTimestamp(timestamp) {
|
|
614
|
-
setTimestamp(this.eventInfo, timestamp);
|
|
615
|
-
}
|
|
616
|
-
getAction() {
|
|
617
|
-
const action = getAction(this.eventInfo);
|
|
618
|
-
if (!action)
|
|
619
|
-
return undefined;
|
|
620
|
-
return {
|
|
621
|
-
name: action[0],
|
|
622
|
-
element: action[1],
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
setAction(action) {
|
|
626
|
-
if (!action) {
|
|
627
|
-
unsetAction(this.eventInfo);
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
setAction(this.eventInfo, action.name, action.element);
|
|
631
|
-
}
|
|
632
|
-
getIsReplay() {
|
|
633
|
-
return getIsReplay(this.eventInfo);
|
|
634
|
-
}
|
|
635
|
-
setIsReplay(replay) {
|
|
636
|
-
setIsReplay(this.eventInfo, replay);
|
|
637
|
-
}
|
|
638
|
-
getResolved() {
|
|
639
|
-
return getResolved(this.eventInfo);
|
|
640
|
-
}
|
|
641
|
-
setResolved(resolved) {
|
|
642
|
-
setResolved(this.eventInfo, resolved);
|
|
643
|
-
}
|
|
644
|
-
clone() {
|
|
645
|
-
return new EventInfoWrapper(cloneEventInfo(this.eventInfo));
|
|
646
|
-
}
|
|
647
|
-
}
|
|
389
|
+
'pagehide',
|
|
390
|
+
'pageshow',
|
|
391
|
+
'visibilitychange',
|
|
392
|
+
// Content visibility events.
|
|
393
|
+
'beforematch',
|
|
394
|
+
];
|
|
395
|
+
/** All event types that are registered in the capture phase. */
|
|
396
|
+
const CAPTURE_EVENT_TYPES = [
|
|
397
|
+
EventType.FOCUS,
|
|
398
|
+
EventType.BLUR,
|
|
399
|
+
EventType.ERROR,
|
|
400
|
+
EventType.LOAD,
|
|
401
|
+
EventType.TOGGLE,
|
|
402
|
+
];
|
|
403
|
+
/**
|
|
404
|
+
* Whether or not an event type should be registered in the capture phase.
|
|
405
|
+
* @param eventType
|
|
406
|
+
* @returns bool
|
|
407
|
+
*/
|
|
408
|
+
const isCaptureEventType = (eventType) => CAPTURE_EVENT_TYPES.indexOf(eventType) >= 0;
|
|
409
|
+
/** All event types that are registered early. */
|
|
410
|
+
const EARLY_EVENT_TYPES = [...BUBBLE_EVENT_TYPES, ...CAPTURE_EVENT_TYPES];
|
|
411
|
+
/**
|
|
412
|
+
* Whether or not an event type is registered in the early contract.
|
|
413
|
+
*/
|
|
414
|
+
const isEarlyEventType = (eventType) => EARLY_EVENT_TYPES.indexOf(eventType) >= 0;
|
|
648
415
|
|
|
649
416
|
/**
|
|
650
417
|
* If on a Macintosh with an extended keyboard, the Enter key located in the
|
|
@@ -706,7 +473,7 @@ function addEventListener(element, eventType, handler) {
|
|
|
706
473
|
// Error and load events (i.e. on images) do not bubble so they are also
|
|
707
474
|
// handled in the capture phase.
|
|
708
475
|
let capture = false;
|
|
709
|
-
if (
|
|
476
|
+
if (isCaptureEventType(eventType)) {
|
|
710
477
|
capture = true;
|
|
711
478
|
}
|
|
712
479
|
element.addEventListener(eventType, handler, capture);
|
|
@@ -1200,87 +967,362 @@ function processSpace(element) {
|
|
|
1200
967
|
return type in PROCESS_SPACE;
|
|
1201
968
|
}
|
|
1202
969
|
/**
|
|
1203
|
-
* Returns whether or not the given element is a text control.
|
|
1204
|
-
* @param el The element.
|
|
1205
|
-
* @return Whether or not the given element is a text control.
|
|
970
|
+
* Returns whether or not the given element is a text control.
|
|
971
|
+
* @param el The element.
|
|
972
|
+
* @return Whether or not the given element is a text control.
|
|
973
|
+
*/
|
|
974
|
+
function isTextControl(el) {
|
|
975
|
+
const type = (el.getAttribute('type') || el.tagName).toUpperCase();
|
|
976
|
+
return type in TEXT_CONTROLS;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Returns if the given element is a native HTML control.
|
|
980
|
+
* @param el The element.
|
|
981
|
+
* @return If the given element is a native HTML control.
|
|
982
|
+
*/
|
|
983
|
+
function isNativeHTMLControl(el) {
|
|
984
|
+
return el.tagName.toUpperCase() in NATIVE_HTML_CONTROLS;
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Returns if the given element is natively activatable. Browsers emit click
|
|
988
|
+
* events for natively activatable elements, even when activated via keyboard.
|
|
989
|
+
* For these elements, we don't need to raise a11y click events.
|
|
990
|
+
* @param el The element.
|
|
991
|
+
* @return If the given element is a native HTML control.
|
|
992
|
+
*/
|
|
993
|
+
function isNativelyActivatable(el) {
|
|
994
|
+
return (el.tagName.toUpperCase() === 'BUTTON' ||
|
|
995
|
+
(!!el.type && el.type.toUpperCase() === 'FILE'));
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* HTML <input> types (not ARIA roles) which will auto-trigger a click event for
|
|
999
|
+
* the Space key, with side-effects. We will not call preventDefault if space is
|
|
1000
|
+
* pressed, nor will we raise a11y click events. For all other elements, we can
|
|
1001
|
+
* suppress the default event (which has no desired side-effects) and handle the
|
|
1002
|
+
* keydown ourselves.
|
|
1003
|
+
*/
|
|
1004
|
+
const PROCESS_SPACE = {
|
|
1005
|
+
'CHECKBOX': true,
|
|
1006
|
+
'FILE': true,
|
|
1007
|
+
'OPTION': true,
|
|
1008
|
+
'RADIO': true,
|
|
1009
|
+
};
|
|
1010
|
+
/** TagNames and Input types for which to not process enter/space as click. */
|
|
1011
|
+
const TEXT_CONTROLS = {
|
|
1012
|
+
'COLOR': true,
|
|
1013
|
+
'DATE': true,
|
|
1014
|
+
'DATETIME': true,
|
|
1015
|
+
'DATETIME-LOCAL': true,
|
|
1016
|
+
'EMAIL': true,
|
|
1017
|
+
'MONTH': true,
|
|
1018
|
+
'NUMBER': true,
|
|
1019
|
+
'PASSWORD': true,
|
|
1020
|
+
'RANGE': true,
|
|
1021
|
+
'SEARCH': true,
|
|
1022
|
+
'TEL': true,
|
|
1023
|
+
'TEXT': true,
|
|
1024
|
+
'TEXTAREA': true,
|
|
1025
|
+
'TIME': true,
|
|
1026
|
+
'URL': true,
|
|
1027
|
+
'WEEK': true,
|
|
1028
|
+
};
|
|
1029
|
+
/** TagNames that are native HTML controls. */
|
|
1030
|
+
const NATIVE_HTML_CONTROLS = {
|
|
1031
|
+
'A': true,
|
|
1032
|
+
'AREA': true,
|
|
1033
|
+
'BUTTON': true,
|
|
1034
|
+
'DIALOG': true,
|
|
1035
|
+
'IMG': true,
|
|
1036
|
+
'INPUT': true,
|
|
1037
|
+
'LINK': true,
|
|
1038
|
+
'MENU': true,
|
|
1039
|
+
'OPTGROUP': true,
|
|
1040
|
+
'OPTION': true,
|
|
1041
|
+
'PROGRESS': true,
|
|
1042
|
+
'SELECT': true,
|
|
1043
|
+
'TEXTAREA': true,
|
|
1044
|
+
};
|
|
1045
|
+
/** Exported for testing. */
|
|
1046
|
+
const testing = {
|
|
1047
|
+
setIsMac(value) {
|
|
1048
|
+
isMac = value;
|
|
1049
|
+
},
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Whether the user agent is running on iOS.
|
|
1054
|
+
*/
|
|
1055
|
+
const isIos = typeof navigator !== 'undefined' && /iPhone|iPad|iPod/.test(navigator.userAgent);
|
|
1056
|
+
/**
|
|
1057
|
+
* A class representing a container node and all the event handlers
|
|
1058
|
+
* installed on it. Used so that handlers can be cleaned up if the
|
|
1059
|
+
* container is removed from the contract.
|
|
1060
|
+
*/
|
|
1061
|
+
class EventContractContainer {
|
|
1062
|
+
/**
|
|
1063
|
+
* @param element The container Element.
|
|
1064
|
+
*/
|
|
1065
|
+
constructor(element) {
|
|
1066
|
+
this.element = element;
|
|
1067
|
+
/**
|
|
1068
|
+
* Array of event handlers and their corresponding event types that are
|
|
1069
|
+
* installed on this container.
|
|
1070
|
+
*
|
|
1071
|
+
*/
|
|
1072
|
+
this.handlerInfos = [];
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Installs the provided installer on the element owned by this container,
|
|
1076
|
+
* and maintains a reference to resulting handler in order to remove it
|
|
1077
|
+
* later if desired.
|
|
1078
|
+
*/
|
|
1079
|
+
addEventListener(eventType, getHandler) {
|
|
1080
|
+
// In iOS, event bubbling doesn't happen automatically in any DOM element,
|
|
1081
|
+
// unless it has an onclick attribute or DOM event handler attached to it.
|
|
1082
|
+
// This breaks JsAction in some cases. See "Making Elements Clickable"
|
|
1083
|
+
// section at http://goo.gl/2VoGnB.
|
|
1084
|
+
//
|
|
1085
|
+
// A workaround for this issue is to change the CSS cursor style to 'pointer'
|
|
1086
|
+
// for the container element, which magically turns on event bubbling. This
|
|
1087
|
+
// solution is described in the comments section at http://goo.gl/6pEO1z.
|
|
1088
|
+
//
|
|
1089
|
+
// We use a navigator.userAgent check here as this problem is present both
|
|
1090
|
+
// on Mobile Safari and thin WebKit wrappers, such as Chrome for iOS.
|
|
1091
|
+
if (isIos) {
|
|
1092
|
+
this.element.style.cursor = 'pointer';
|
|
1093
|
+
}
|
|
1094
|
+
this.handlerInfos.push(addEventListener(this.element, eventType, getHandler(this.element)));
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Removes all the handlers installed on this container.
|
|
1098
|
+
*/
|
|
1099
|
+
cleanUp() {
|
|
1100
|
+
for (let i = 0; i < this.handlerInfos.length; i++) {
|
|
1101
|
+
removeEventListener(this.element, this.handlerInfos[i]);
|
|
1102
|
+
}
|
|
1103
|
+
this.handlerInfos = [];
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
const Char = {
|
|
1108
|
+
/**
|
|
1109
|
+
* The separator between the namespace and the action name in the
|
|
1110
|
+
* jsaction attribute value.
|
|
1111
|
+
*/
|
|
1112
|
+
NAMESPACE_ACTION_SEPARATOR: '.',
|
|
1113
|
+
/**
|
|
1114
|
+
* The separator between the event name and action in the jsaction
|
|
1115
|
+
* attribute value.
|
|
1116
|
+
*/
|
|
1117
|
+
EVENT_ACTION_SEPARATOR: ':',
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
/** Added for readability when accessing stable property names. */
|
|
1121
|
+
function getEventType(eventInfo) {
|
|
1122
|
+
return eventInfo.eventType;
|
|
1123
|
+
}
|
|
1124
|
+
/** Added for readability when accessing stable property names. */
|
|
1125
|
+
function setEventType(eventInfo, eventType) {
|
|
1126
|
+
eventInfo.eventType = eventType;
|
|
1127
|
+
}
|
|
1128
|
+
/** Added for readability when accessing stable property names. */
|
|
1129
|
+
function getEvent(eventInfo) {
|
|
1130
|
+
return eventInfo.event;
|
|
1131
|
+
}
|
|
1132
|
+
/** Added for readability when accessing stable property names. */
|
|
1133
|
+
function setEvent(eventInfo, event) {
|
|
1134
|
+
eventInfo.event = event;
|
|
1135
|
+
}
|
|
1136
|
+
/** Added for readability when accessing stable property names. */
|
|
1137
|
+
function getTargetElement(eventInfo) {
|
|
1138
|
+
return eventInfo.targetElement;
|
|
1139
|
+
}
|
|
1140
|
+
/** Added for readability when accessing stable property names. */
|
|
1141
|
+
function setTargetElement(eventInfo, targetElement) {
|
|
1142
|
+
eventInfo.targetElement = targetElement;
|
|
1143
|
+
}
|
|
1144
|
+
/** Added for readability when accessing stable property names. */
|
|
1145
|
+
function getContainer(eventInfo) {
|
|
1146
|
+
return eventInfo.eic;
|
|
1147
|
+
}
|
|
1148
|
+
/** Added for readability when accessing stable property names. */
|
|
1149
|
+
function setContainer(eventInfo, container) {
|
|
1150
|
+
eventInfo.eic = container;
|
|
1151
|
+
}
|
|
1152
|
+
/** Added for readability when accessing stable property names. */
|
|
1153
|
+
function getTimestamp(eventInfo) {
|
|
1154
|
+
return eventInfo.timeStamp;
|
|
1155
|
+
}
|
|
1156
|
+
/** Added for readability when accessing stable property names. */
|
|
1157
|
+
function setTimestamp(eventInfo, timestamp) {
|
|
1158
|
+
eventInfo.timeStamp = timestamp;
|
|
1159
|
+
}
|
|
1160
|
+
/** Added for readability when accessing stable property names. */
|
|
1161
|
+
function getAction(eventInfo) {
|
|
1162
|
+
return eventInfo.eia;
|
|
1163
|
+
}
|
|
1164
|
+
/** Added for readability when accessing stable property names. */
|
|
1165
|
+
function setAction(eventInfo, actionName, actionElement) {
|
|
1166
|
+
eventInfo.eia = [actionName, actionElement];
|
|
1167
|
+
}
|
|
1168
|
+
/** Added for readability when accessing stable property names. */
|
|
1169
|
+
function unsetAction(eventInfo) {
|
|
1170
|
+
eventInfo.eia = undefined;
|
|
1171
|
+
}
|
|
1172
|
+
/** Added for readability when accessing stable property names. */
|
|
1173
|
+
function getActionName(actionInfo) {
|
|
1174
|
+
return actionInfo[0];
|
|
1175
|
+
}
|
|
1176
|
+
/** Added for readability when accessing stable property names. */
|
|
1177
|
+
function getActionElement(actionInfo) {
|
|
1178
|
+
return actionInfo[1];
|
|
1179
|
+
}
|
|
1180
|
+
/** Added for readability when accessing stable property names. */
|
|
1181
|
+
function getIsReplay(eventInfo) {
|
|
1182
|
+
return eventInfo.eirp;
|
|
1183
|
+
}
|
|
1184
|
+
/** Added for readability when accessing stable property names. */
|
|
1185
|
+
function setIsReplay(eventInfo, replay) {
|
|
1186
|
+
eventInfo.eirp = replay;
|
|
1187
|
+
}
|
|
1188
|
+
/** Added for readability when accessing stable property names. */
|
|
1189
|
+
function getA11yClickKey(eventInfo) {
|
|
1190
|
+
return eventInfo.eiack;
|
|
1191
|
+
}
|
|
1192
|
+
/** Added for readability when accessing stable property names. */
|
|
1193
|
+
function setA11yClickKey(eventInfo, a11yClickKey) {
|
|
1194
|
+
eventInfo.eiack = a11yClickKey;
|
|
1195
|
+
}
|
|
1196
|
+
/** Added for readability when accessing stable property names. */
|
|
1197
|
+
function getResolved(eventInfo) {
|
|
1198
|
+
return eventInfo.eir;
|
|
1199
|
+
}
|
|
1200
|
+
/** Added for readability when accessing stable property names. */
|
|
1201
|
+
function setResolved(eventInfo, resolved) {
|
|
1202
|
+
eventInfo.eir = resolved;
|
|
1203
|
+
}
|
|
1204
|
+
/** Clones an `EventInfo` */
|
|
1205
|
+
function cloneEventInfo(eventInfo) {
|
|
1206
|
+
return {
|
|
1207
|
+
eventType: eventInfo.eventType,
|
|
1208
|
+
event: eventInfo.event,
|
|
1209
|
+
targetElement: eventInfo.targetElement,
|
|
1210
|
+
eic: eventInfo.eic,
|
|
1211
|
+
eia: eventInfo.eia,
|
|
1212
|
+
timeStamp: eventInfo.timeStamp,
|
|
1213
|
+
eirp: eventInfo.eirp,
|
|
1214
|
+
eiack: eventInfo.eiack,
|
|
1215
|
+
eir: eventInfo.eir,
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Utility function for creating an `EventInfo`.
|
|
1220
|
+
*
|
|
1221
|
+
* This can be used from code-size sensitive compilation units, as taking
|
|
1222
|
+
* parameters vs. an `Object` literal reduces code size.
|
|
1206
1223
|
*/
|
|
1207
|
-
function
|
|
1208
|
-
|
|
1209
|
-
|
|
1224
|
+
function createEventInfoFromParameters(eventType, event, targetElement, container, timestamp, action, isReplay, a11yClickKey) {
|
|
1225
|
+
return {
|
|
1226
|
+
eventType,
|
|
1227
|
+
event,
|
|
1228
|
+
targetElement,
|
|
1229
|
+
eic: container,
|
|
1230
|
+
timeStamp: timestamp,
|
|
1231
|
+
eia: action,
|
|
1232
|
+
eirp: isReplay,
|
|
1233
|
+
eiack: a11yClickKey,
|
|
1234
|
+
};
|
|
1210
1235
|
}
|
|
1211
1236
|
/**
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1237
|
+
* Utility function for creating an `EventInfo`.
|
|
1238
|
+
*
|
|
1239
|
+
* This should be used in compilation units that are less sensitive to code
|
|
1240
|
+
* size.
|
|
1215
1241
|
*/
|
|
1216
|
-
function
|
|
1217
|
-
return
|
|
1242
|
+
function createEventInfo({ eventType, event, targetElement, container, timestamp, action, isReplay, a11yClickKey, }) {
|
|
1243
|
+
return {
|
|
1244
|
+
eventType,
|
|
1245
|
+
event,
|
|
1246
|
+
targetElement,
|
|
1247
|
+
eic: container,
|
|
1248
|
+
timeStamp: timestamp,
|
|
1249
|
+
eia: action ? [action.name, action.element] : undefined,
|
|
1250
|
+
eirp: isReplay,
|
|
1251
|
+
eiack: a11yClickKey,
|
|
1252
|
+
};
|
|
1218
1253
|
}
|
|
1219
1254
|
/**
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
* @return If the given element is a native HTML control.
|
|
1255
|
+
* Utility class around an `EventInfo`.
|
|
1256
|
+
*
|
|
1257
|
+
* This should be used in compilation units that are less sensitive to code
|
|
1258
|
+
* size.
|
|
1225
1259
|
*/
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1260
|
+
class EventInfoWrapper {
|
|
1261
|
+
constructor(eventInfo) {
|
|
1262
|
+
this.eventInfo = eventInfo;
|
|
1263
|
+
}
|
|
1264
|
+
getEventType() {
|
|
1265
|
+
return getEventType(this.eventInfo);
|
|
1266
|
+
}
|
|
1267
|
+
setEventType(eventType) {
|
|
1268
|
+
setEventType(this.eventInfo, eventType);
|
|
1269
|
+
}
|
|
1270
|
+
getEvent() {
|
|
1271
|
+
return getEvent(this.eventInfo);
|
|
1272
|
+
}
|
|
1273
|
+
setEvent(event) {
|
|
1274
|
+
setEvent(this.eventInfo, event);
|
|
1275
|
+
}
|
|
1276
|
+
getTargetElement() {
|
|
1277
|
+
return getTargetElement(this.eventInfo);
|
|
1278
|
+
}
|
|
1279
|
+
setTargetElement(targetElement) {
|
|
1280
|
+
setTargetElement(this.eventInfo, targetElement);
|
|
1281
|
+
}
|
|
1282
|
+
getContainer() {
|
|
1283
|
+
return getContainer(this.eventInfo);
|
|
1284
|
+
}
|
|
1285
|
+
setContainer(container) {
|
|
1286
|
+
setContainer(this.eventInfo, container);
|
|
1287
|
+
}
|
|
1288
|
+
getTimestamp() {
|
|
1289
|
+
return getTimestamp(this.eventInfo);
|
|
1290
|
+
}
|
|
1291
|
+
setTimestamp(timestamp) {
|
|
1292
|
+
setTimestamp(this.eventInfo, timestamp);
|
|
1293
|
+
}
|
|
1294
|
+
getAction() {
|
|
1295
|
+
const action = getAction(this.eventInfo);
|
|
1296
|
+
if (!action)
|
|
1297
|
+
return undefined;
|
|
1298
|
+
return {
|
|
1299
|
+
name: action[0],
|
|
1300
|
+
element: action[1],
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
setAction(action) {
|
|
1304
|
+
if (!action) {
|
|
1305
|
+
unsetAction(this.eventInfo);
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
setAction(this.eventInfo, action.name, action.element);
|
|
1309
|
+
}
|
|
1310
|
+
getIsReplay() {
|
|
1311
|
+
return getIsReplay(this.eventInfo);
|
|
1312
|
+
}
|
|
1313
|
+
setIsReplay(replay) {
|
|
1314
|
+
setIsReplay(this.eventInfo, replay);
|
|
1315
|
+
}
|
|
1316
|
+
getResolved() {
|
|
1317
|
+
return getResolved(this.eventInfo);
|
|
1318
|
+
}
|
|
1319
|
+
setResolved(resolved) {
|
|
1320
|
+
setResolved(this.eventInfo, resolved);
|
|
1321
|
+
}
|
|
1322
|
+
clone() {
|
|
1323
|
+
return new EventInfoWrapper(cloneEventInfo(this.eventInfo));
|
|
1324
|
+
}
|
|
1229
1325
|
}
|
|
1230
|
-
/**
|
|
1231
|
-
* HTML <input> types (not ARIA roles) which will auto-trigger a click event for
|
|
1232
|
-
* the Space key, with side-effects. We will not call preventDefault if space is
|
|
1233
|
-
* pressed, nor will we raise a11y click events. For all other elements, we can
|
|
1234
|
-
* suppress the default event (which has no desired side-effects) and handle the
|
|
1235
|
-
* keydown ourselves.
|
|
1236
|
-
*/
|
|
1237
|
-
const PROCESS_SPACE = {
|
|
1238
|
-
'CHECKBOX': true,
|
|
1239
|
-
'FILE': true,
|
|
1240
|
-
'OPTION': true,
|
|
1241
|
-
'RADIO': true,
|
|
1242
|
-
};
|
|
1243
|
-
/** TagNames and Input types for which to not process enter/space as click. */
|
|
1244
|
-
const TEXT_CONTROLS = {
|
|
1245
|
-
'COLOR': true,
|
|
1246
|
-
'DATE': true,
|
|
1247
|
-
'DATETIME': true,
|
|
1248
|
-
'DATETIME-LOCAL': true,
|
|
1249
|
-
'EMAIL': true,
|
|
1250
|
-
'MONTH': true,
|
|
1251
|
-
'NUMBER': true,
|
|
1252
|
-
'PASSWORD': true,
|
|
1253
|
-
'RANGE': true,
|
|
1254
|
-
'SEARCH': true,
|
|
1255
|
-
'TEL': true,
|
|
1256
|
-
'TEXT': true,
|
|
1257
|
-
'TEXTAREA': true,
|
|
1258
|
-
'TIME': true,
|
|
1259
|
-
'URL': true,
|
|
1260
|
-
'WEEK': true,
|
|
1261
|
-
};
|
|
1262
|
-
/** TagNames that are native HTML controls. */
|
|
1263
|
-
const NATIVE_HTML_CONTROLS = {
|
|
1264
|
-
'A': true,
|
|
1265
|
-
'AREA': true,
|
|
1266
|
-
'BUTTON': true,
|
|
1267
|
-
'DIALOG': true,
|
|
1268
|
-
'IMG': true,
|
|
1269
|
-
'INPUT': true,
|
|
1270
|
-
'LINK': true,
|
|
1271
|
-
'MENU': true,
|
|
1272
|
-
'OPTGROUP': true,
|
|
1273
|
-
'OPTION': true,
|
|
1274
|
-
'PROGRESS': true,
|
|
1275
|
-
'SELECT': true,
|
|
1276
|
-
'TEXTAREA': true,
|
|
1277
|
-
};
|
|
1278
|
-
/** Exported for testing. */
|
|
1279
|
-
const testing = {
|
|
1280
|
-
setIsMac(value) {
|
|
1281
|
-
isMac = value;
|
|
1282
|
-
},
|
|
1283
|
-
};
|
|
1284
1326
|
|
|
1285
1327
|
/**
|
|
1286
1328
|
* Since maps from event to action are immutable we can use a single map
|
|
@@ -1742,66 +1784,6 @@ function registerDispatcher(eventContract, dispatcher) {
|
|
|
1742
1784
|
}, Restriction.I_AM_THE_JSACTION_FRAMEWORK);
|
|
1743
1785
|
}
|
|
1744
1786
|
|
|
1745
|
-
/**
|
|
1746
|
-
* Whether the user agent is running on iOS.
|
|
1747
|
-
*/
|
|
1748
|
-
const isIos = typeof navigator !== 'undefined' && /iPhone|iPad|iPod/.test(navigator.userAgent);
|
|
1749
|
-
/**
|
|
1750
|
-
* A class representing a container node and all the event handlers
|
|
1751
|
-
* installed on it. Used so that handlers can be cleaned up if the
|
|
1752
|
-
* container is removed from the contract.
|
|
1753
|
-
*/
|
|
1754
|
-
class EventContractContainer {
|
|
1755
|
-
/**
|
|
1756
|
-
* @param element The container Element.
|
|
1757
|
-
*/
|
|
1758
|
-
constructor(element) {
|
|
1759
|
-
this.element = element;
|
|
1760
|
-
/**
|
|
1761
|
-
* Array of event handlers and their corresponding event types that are
|
|
1762
|
-
* installed on this container.
|
|
1763
|
-
*
|
|
1764
|
-
*/
|
|
1765
|
-
this.handlerInfos = [];
|
|
1766
|
-
}
|
|
1767
|
-
/**
|
|
1768
|
-
* Installs the provided installer on the element owned by this container,
|
|
1769
|
-
* and maintains a reference to resulting handler in order to remove it
|
|
1770
|
-
* later if desired.
|
|
1771
|
-
*/
|
|
1772
|
-
addEventListener(eventType, getHandler) {
|
|
1773
|
-
// In iOS, event bubbling doesn't happen automatically in any DOM element,
|
|
1774
|
-
// unless it has an onclick attribute or DOM event handler attached to it.
|
|
1775
|
-
// This breaks JsAction in some cases. See "Making Elements Clickable"
|
|
1776
|
-
// section at http://goo.gl/2VoGnB.
|
|
1777
|
-
//
|
|
1778
|
-
// A workaround for this issue is to change the CSS cursor style to 'pointer'
|
|
1779
|
-
// for the container element, which magically turns on event bubbling. This
|
|
1780
|
-
// solution is described in the comments section at http://goo.gl/6pEO1z.
|
|
1781
|
-
//
|
|
1782
|
-
// We use a navigator.userAgent check here as this problem is present both
|
|
1783
|
-
// on Mobile Safari and thin WebKit wrappers, such as Chrome for iOS.
|
|
1784
|
-
if (isIos) {
|
|
1785
|
-
this.element.style.cursor = 'pointer';
|
|
1786
|
-
}
|
|
1787
|
-
this.handlerInfos.push(addEventListener(this.element, eventType, getHandler(this.element)));
|
|
1788
|
-
}
|
|
1789
|
-
/**
|
|
1790
|
-
* Removes all the handlers installed on this container.
|
|
1791
|
-
*/
|
|
1792
|
-
cleanUp() {
|
|
1793
|
-
for (let i = 0; i < this.handlerInfos.length; i++) {
|
|
1794
|
-
removeEventListener(this.element, this.handlerInfos[i]);
|
|
1795
|
-
}
|
|
1796
|
-
this.handlerInfos = [];
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
/**
|
|
1801
|
-
* @define Support for accessible click actions. This flag can be overridden in
|
|
1802
|
-
* a build rule.
|
|
1803
|
-
*/
|
|
1804
|
-
const A11Y_CLICK_SUPPORT = false;
|
|
1805
1787
|
/**
|
|
1806
1788
|
* @define Support for the non-bubbling mouseenter and mouseleave events. This
|
|
1807
1789
|
* flag can be overridden in a build rule.
|
|
@@ -1823,7 +1805,6 @@ const MOUSE_SPECIAL_SUPPORT = false;
|
|
|
1823
1805
|
* be delay loaded in a generic way.
|
|
1824
1806
|
*/
|
|
1825
1807
|
class EventContract {
|
|
1826
|
-
static { this.A11Y_CLICK_SUPPORT = A11Y_CLICK_SUPPORT; }
|
|
1827
1808
|
static { this.MOUSE_SPECIAL_SUPPORT = MOUSE_SPECIAL_SUPPORT; }
|
|
1828
1809
|
constructor(containerManager, useActionResolver) {
|
|
1829
1810
|
this.useActionResolver = useActionResolver;
|
|
@@ -1889,7 +1870,7 @@ class EventContract {
|
|
|
1889
1870
|
if (eventType in this.eventHandlers || !this.containerManager) {
|
|
1890
1871
|
return;
|
|
1891
1872
|
}
|
|
1892
|
-
if (!EventContract.MOUSE_SPECIAL_SUPPORT &&
|
|
1873
|
+
if (!EventContract.MOUSE_SPECIAL_SUPPORT && MOUSE_SPECIAL_EVENT_TYPES.indexOf(eventType) >= 0) {
|
|
1893
1874
|
return;
|
|
1894
1875
|
}
|
|
1895
1876
|
const eventHandler = (eventType, event, container) => {
|
|
@@ -1914,10 +1895,9 @@ class EventContract {
|
|
|
1914
1895
|
* in the provided event contract. Once all the events are replayed, it cleans
|
|
1915
1896
|
* up the early contract.
|
|
1916
1897
|
*/
|
|
1917
|
-
replayEarlyEvents(
|
|
1898
|
+
replayEarlyEvents(earlyJsactionData = window._ejsa) {
|
|
1918
1899
|
// Check if the early contract is present and prevent calling this function
|
|
1919
1900
|
// more than once.
|
|
1920
|
-
const earlyJsactionData = earlyJsactionContainer._ejsa;
|
|
1921
1901
|
if (!earlyJsactionData) {
|
|
1922
1902
|
return;
|
|
1923
1903
|
}
|
|
@@ -1938,7 +1918,7 @@ class EventContract {
|
|
|
1938
1918
|
const earlyEventHandler = earlyJsactionData.h;
|
|
1939
1919
|
removeEventListeners(earlyJsactionData.c, earlyJsactionData.et, earlyEventHandler);
|
|
1940
1920
|
removeEventListeners(earlyJsactionData.c, earlyJsactionData.etc, earlyEventHandler, true);
|
|
1941
|
-
delete
|
|
1921
|
+
delete window._ejsa;
|
|
1942
1922
|
}
|
|
1943
1923
|
/**
|
|
1944
1924
|
* Returns all JSAction event types that have been registered for a given
|
|
@@ -2023,62 +2003,5 @@ function removeEventListeners(container, eventTypes, earlyEventHandler, capture)
|
|
|
2023
2003
|
*/
|
|
2024
2004
|
function addDeferredA11yClickSupport(eventContract) { }
|
|
2025
2005
|
|
|
2026
|
-
|
|
2027
|
-
* EarlyEventContract intercepts events in the bubbling phase at the
|
|
2028
|
-
* boundary of the document body. This mapping will be passed to the
|
|
2029
|
-
* late-loaded EventContract.
|
|
2030
|
-
*/
|
|
2031
|
-
class EarlyEventContract {
|
|
2032
|
-
constructor(replaySink = window, container = window.document.documentElement) {
|
|
2033
|
-
this.replaySink = replaySink;
|
|
2034
|
-
this.container = container;
|
|
2035
|
-
replaySink._ejsa = {
|
|
2036
|
-
c: container,
|
|
2037
|
-
q: [],
|
|
2038
|
-
et: [],
|
|
2039
|
-
etc: [],
|
|
2040
|
-
h: (event) => {
|
|
2041
|
-
const eventInfo = createEventInfoFromParameters(event.type, event, event.target, container, Date.now());
|
|
2042
|
-
replaySink._ejsa.q.push(eventInfo);
|
|
2043
|
-
},
|
|
2044
|
-
};
|
|
2045
|
-
}
|
|
2046
|
-
/**
|
|
2047
|
-
* Installs a list of event types for container .
|
|
2048
|
-
*/
|
|
2049
|
-
addEvents(types, capture) {
|
|
2050
|
-
const replaySink = this.replaySink._ejsa;
|
|
2051
|
-
for (let idx = 0; idx < types.length; idx++) {
|
|
2052
|
-
const eventType = types[idx];
|
|
2053
|
-
const eventTypes = capture ? replaySink.etc : replaySink.et;
|
|
2054
|
-
eventTypes.push(eventType);
|
|
2055
|
-
this.container.addEventListener(eventType, replaySink.h, capture);
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
}
|
|
2059
|
-
|
|
2060
|
-
/**
|
|
2061
|
-
* Provides a factory function for bootstrapping an event contract on a
|
|
2062
|
-
* specified object (by default, exposed on the `window`).
|
|
2063
|
-
* @param field The property on the object that the event contract will be placed on.
|
|
2064
|
-
* @param container The container that listens to events
|
|
2065
|
-
* @param appId A given identifier for an application. If there are multiple apps on the page
|
|
2066
|
-
* then this is how contracts can be initialized for each one.
|
|
2067
|
-
* @param eventTypes An array of event names that should be listened to.
|
|
2068
|
-
* @param captureEventTypes An array of event names that should be listened to with capture.
|
|
2069
|
-
* @param earlyJsactionTracker The object that should receive the event contract.
|
|
2070
|
-
*/
|
|
2071
|
-
function bootstrapEarlyEventContract(field, container, appId, eventTypes, captureEventTypes, earlyJsactionTracker = window) {
|
|
2072
|
-
if (!earlyJsactionTracker[field]) {
|
|
2073
|
-
earlyJsactionTracker[field] = {};
|
|
2074
|
-
}
|
|
2075
|
-
earlyJsactionTracker[field][appId] = {};
|
|
2076
|
-
const eventContract = new EarlyEventContract(earlyJsactionTracker[field][appId], container);
|
|
2077
|
-
if (eventTypes)
|
|
2078
|
-
eventContract.addEvents(eventTypes);
|
|
2079
|
-
if (captureEventTypes)
|
|
2080
|
-
eventContract.addEvents(captureEventTypes, true);
|
|
2081
|
-
}
|
|
2082
|
-
|
|
2083
|
-
export { Attribute, EventContract, EventContractContainer, EventDispatcher, EventInfoWrapper, EventPhase, bootstrapEarlyEventContract, isCaptureEvent, isSupportedEvent, registerDispatcher, registerEventType, unregisterEventType };
|
|
2006
|
+
export { Attribute, EventContract, EventContractContainer, EventDispatcher, EventInfoWrapper, EventPhase, getDefaulted as getActionCache, isCaptureEventType, isEarlyEventType, registerDispatcher };
|
|
2084
2007
|
//# sourceMappingURL=event-dispatch.mjs.map
|