@angular/core 18.1.0-next.4 → 18.1.0-rc.0

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 (42) hide show
  1. package/esm2022/primitives/event-dispatch/index.mjs +3 -2
  2. package/esm2022/primitives/event-dispatch/src/action_resolver.mjs +3 -3
  3. package/esm2022/primitives/event-dispatch/src/attribute.mjs +16 -52
  4. package/esm2022/primitives/event-dispatch/src/cache.mjs +17 -6
  5. package/esm2022/primitives/event-dispatch/src/char.mjs +1 -16
  6. package/esm2022/primitives/event-dispatch/src/event.mjs +2 -3
  7. package/esm2022/primitives/event-dispatch/src/eventcontract.mjs +5 -66
  8. package/esm2022/primitives/event-dispatch/src/property.mjs +17 -22
  9. package/esm2022/primitives/signals/index.mjs +3 -3
  10. package/esm2022/primitives/signals/src/signal.mjs +4 -1
  11. package/esm2022/src/change_detection/scheduling/zoneless_scheduling_impl.mjs +2 -2
  12. package/esm2022/src/core_private_export.mjs +3 -1
  13. package/esm2022/src/event_delegation_utils.mjs +40 -23
  14. package/esm2022/src/event_dispatch/event_delegation.mjs +38 -0
  15. package/esm2022/src/hydration/annotate.mjs +3 -3
  16. package/esm2022/src/hydration/event_replay.mjs +5 -5
  17. package/esm2022/src/render3/component_ref.mjs +1 -1
  18. package/esm2022/src/version.mjs +1 -1
  19. package/esm2022/testing/src/logger.mjs +3 -3
  20. package/fesm2022/core.mjs +75 -30
  21. package/fesm2022/core.mjs.map +1 -1
  22. package/fesm2022/primitives/event-dispatch.mjs +53 -242
  23. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  24. package/fesm2022/primitives/signals.mjs +5 -2
  25. package/fesm2022/primitives/signals.mjs.map +1 -1
  26. package/fesm2022/rxjs-interop.mjs +1 -1
  27. package/fesm2022/testing.mjs +1 -1
  28. package/index.d.ts +31 -2
  29. package/package.json +1 -1
  30. package/primitives/event-dispatch/index.d.ts +22 -102
  31. package/primitives/signals/index.d.ts +10 -1
  32. package/rxjs-interop/index.d.ts +1 -1
  33. package/schematics/migrations/after-render-phase/bundle.js +12 -12
  34. package/schematics/migrations/http-providers/bundle.js +15 -15
  35. package/schematics/migrations/invalid-two-way-bindings/bundle.js +184 -167
  36. package/schematics/migrations/invalid-two-way-bindings/bundle.js.map +2 -2
  37. package/schematics/ng-generate/control-flow-migration/bundle.js +192 -175
  38. package/schematics/ng-generate/control-flow-migration/bundle.js.map +2 -2
  39. package/schematics/ng-generate/standalone-migration/bundle.js +552 -471
  40. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  41. package/testing/index.d.ts +1 -1
  42. package/esm2022/primitives/event-dispatch/src/dom.mjs +0 -48
@@ -1,60 +1,24 @@
1
1
  /**
2
- * @license Angular v18.1.0-next.4
2
+ * @license Angular v18.1.0-rc.0
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
- /**
8
- * The jsaction attribute defines a mapping of a DOM event to a
9
- * generic event (aka jsaction), to which the actual event handlers
10
- * that implement the behavior of the application are bound. The
11
- * value is a semicolon separated list of colon separated pairs of
12
- * an optional DOM event name and a jsaction name. If the optional
13
- * DOM event name is omitted, 'click' is assumed. The jsaction names
14
- * are dot separated pairs of a namespace and a simple jsaction
15
- * name.
16
- *
17
- * See grammar in README.md for expected syntax in the attribute value.
18
- */
19
- const JSACTION$1 = 'jsaction';
20
- /**
21
- * The oi attribute is a log impression tag for impression logging
22
- * and action tracking. For an element that carries a jsaction
23
- * attribute, the element is identified for the purpose of
24
- * impression logging and click tracking by the dot separated path
25
- * of all oi attributes in the chain of ancestors of the element.
26
- *
27
- * Used by ActionFlow.
28
- */
29
- const OI$1 = 'oi';
30
- /**
31
- * The ved attribute is an encoded ClickTrackingCGI proto to track
32
- * visual elements.
33
- *
34
- * Used by ActionFlow.
35
- */
36
- const VED = 'ved';
37
- /**
38
- * The vet attribute is the visual element type used to identify tracked
39
- * visual elements.
40
- */
41
- const VET = 'vet';
42
- /**
43
- * Support for iteration on reprocessing.
44
- *
45
- * Used by ActionFlow.
46
- */
47
- const JSINSTANCE = 'jsinstance';
48
- /**
49
- * All click jsactions that happen on the element that carries this
50
- * attribute or its descendants are automatically logged.
51
- * Impressions of jsactions on these elements are tracked too, if
52
- * requested by the impression() method of ActionFlow.
53
- *
54
- * Used by ActionFlow.
55
- */
56
- const JSTRACK = 'jstrack';
57
- const Attribute = { JSACTION: JSACTION$1, OI: OI$1, VED, VET, JSINSTANCE, JSTRACK };
7
+ const Attribute = {
8
+ /**
9
+ * The jsaction attribute defines a mapping of a DOM event to a
10
+ * generic event (aka jsaction), to which the actual event handlers
11
+ * that implement the behavior of the application are bound. The
12
+ * value is a semicolon separated list of colon separated pairs of
13
+ * an optional DOM event name and a jsaction name. If the optional
14
+ * DOM event name is omitted, 'click' is assumed. The jsaction names
15
+ * are dot separated pairs of a namespace and a simple jsaction
16
+ * name.
17
+ *
18
+ * See grammar in README.md for expected syntax in the attribute value.
19
+ */
20
+ JSACTION: 'jsaction',
21
+ };
58
22
 
59
23
  const Char = {
60
24
  /**
@@ -67,21 +31,6 @@ const Char = {
67
31
  * attribute value.
68
32
  */
69
33
  EVENT_ACTION_SEPARATOR: ':',
70
- /**
71
- * The separator between the logged oi attribute values in the &oi=
72
- * URL parameter value.
73
- */
74
- OI_SEPARATOR: '.',
75
- /**
76
- * The separator between the key and the value pairs in the &cad=
77
- * URL parameter value.
78
- */
79
- CAD_KEY_VALUE_SEPARATOR: ':',
80
- /**
81
- * The separator between the key-value pairs in the &cad= URL
82
- * parameter value.
83
- */
84
- CAD_SEPARATOR: ',',
85
34
  };
86
35
 
87
36
  /*
@@ -405,35 +354,41 @@ const CAPTURE_EVENTS = [
405
354
  EventType.TOGGLE,
406
355
  ];
407
356
 
408
- /**
409
- * The parsed value of the jsaction attribute is stored in this
410
- * property on the DOM node. The parsed value is an Object. The
411
- * property names of the object are the events; the values are the
412
- * names of the actions. This property is attached even on nodes
413
- * that don't have a jsaction attribute as an optimization, because
414
- * property lookup is faster than attribute access.
415
- */
416
- const JSACTION = '__jsaction';
417
- /** The value of the oi attribute as a property, for faster access. */
418
- const OI = '__oi';
419
- /**
420
- * The owner property references an a logical owner for a DOM node. JSAction
421
- * will follow this reference instead of parentNode when traversing the DOM
422
- * to find jsaction attributes. This allows overlaying a logical structure
423
- * over a document where the DOM structure can't reflect that structure.
424
- */
425
- const OWNER = '__owner';
426
357
  /** All properties that are used by jsaction. */
427
358
  const Property = {
428
- JSACTION,
429
- OI,
430
- OWNER,
359
+ /**
360
+ * The parsed value of the jsaction attribute is stored in this
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',
431
375
  };
432
376
 
433
377
  /**
434
378
  * Map from jsaction annotation to a parsed map from event name to action name.
435
379
  */
436
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
+ }
437
392
  /**
438
393
  * Reads the jsaction parser cache from the given DOM Element.
439
394
  *
@@ -442,7 +397,7 @@ const parseCache = {};
442
397
  */
443
398
  function get(element) {
444
399
  // @ts-ignore
445
- return element[JSACTION];
400
+ return element[Property.JSACTION];
446
401
  }
447
402
  /**
448
403
  * Writes the jsaction parser cache to the given DOM Element.
@@ -453,7 +408,7 @@ function get(element) {
453
408
  */
454
409
  function set(element, actionMap) {
455
410
  // @ts-ignore
456
- element[JSACTION] = actionMap;
411
+ element[Property.JSACTION] = actionMap;
457
412
  }
458
413
  /**
459
414
  * Looks up the parsed action map from the source jsaction attribute value.
@@ -479,8 +434,8 @@ function setParsed(text, parsed) {
479
434
  * @param element .
480
435
  */
481
436
  function clear(element) {
482
- if (JSACTION in element) {
483
- delete element[JSACTION];
437
+ if (Property.JSACTION in element) {
438
+ delete element[Property.JSACTION];
484
439
  }
485
440
  }
486
441
 
@@ -691,47 +646,6 @@ class EventInfoWrapper {
691
646
  }
692
647
  }
693
648
 
694
- /**
695
- * Determines if one node is contained within another. Adapted from
696
- * {@see goog.dom.contains}.
697
- * @param node Node that should contain otherNode.
698
- * @param otherNode Node being contained.
699
- * @return True if otherNode is contained within node.
700
- */
701
- function contains(node, otherNode) {
702
- if (otherNode === null) {
703
- return false;
704
- }
705
- // We use browser specific methods for this if available since it is faster
706
- // that way.
707
- // IE DOM
708
- if ('contains' in node && otherNode.nodeType === 1) {
709
- return node.contains(otherNode);
710
- }
711
- // W3C DOM Level 3
712
- if ('compareDocumentPosition' in node) {
713
- return node === otherNode || Boolean(node.compareDocumentPosition(otherNode) & 16);
714
- }
715
- // W3C DOM Level 1
716
- while (otherNode && node !== otherNode) {
717
- otherNode = otherNode.parentNode;
718
- }
719
- return otherNode === node;
720
- }
721
- /**
722
- * Helper method for broadcastCustomEvent. Returns true if any member of
723
- * the set is an ancestor of element.
724
- */
725
- function hasAncestorInNodeList(element, nodeList) {
726
- for (let idx = 0; idx < nodeList.length; ++idx) {
727
- const member = nodeList[idx];
728
- if (member !== element && contains(member, element)) {
729
- return true;
730
- }
731
- }
732
- return false;
733
- }
734
-
735
649
  /**
736
650
  * If on a Macintosh with an extended keyboard, the Enter key located in the
737
651
  * numeric pad has a different ASCII code.
@@ -1097,7 +1011,7 @@ function isMouseSpecialEvent(e, type, element) {
1097
1011
  (e.type === EventType.MOUSEOUT && type === EventType.MOUSELEAVE) ||
1098
1012
  (e.type === EventType.POINTEROVER && type === EventType.POINTERENTER) ||
1099
1013
  (e.type === EventType.POINTEROUT && type === EventType.POINTERLEAVE)) &&
1100
- (!related || (related !== element && !contains(element, related))));
1014
+ (!related || (related !== element && !element.contains(related))));
1101
1015
  }
1102
1016
  /**
1103
1017
  * Creates a new EventLike object for a mouseenter/mouseleave event that's
@@ -1517,7 +1431,7 @@ class ActionResolver {
1517
1431
  * shadow root if needed.
1518
1432
  */
1519
1433
  getParentNode(element) {
1520
- const owner = element[OWNER];
1434
+ const owner = element[Property.OWNER];
1521
1435
  if (owner) {
1522
1436
  return owner;
1523
1437
  }
@@ -1883,50 +1797,6 @@ class EventContractContainer {
1883
1797
  }
1884
1798
  }
1885
1799
 
1886
- /**
1887
- * Update `EventInfo` to be `eventType = 'click'` and sets `a11yClickKey` if it
1888
- * is a a11y click.
1889
- */
1890
- function updateEventInfoForA11yClick(eventInfo) {
1891
- if (!isActionKeyEvent(getEvent(eventInfo))) {
1892
- return;
1893
- }
1894
- setA11yClickKey(eventInfo, true);
1895
- // A 'click' triggered by a DOM keypress should be mapped to the 'click'
1896
- // jsaction.
1897
- setEventType(eventInfo, EventType.CLICK);
1898
- }
1899
- /**
1900
- * Call `preventDefault` on an a11y click if it is space key or to prevent the
1901
- * browser's default action for native HTML controls.
1902
- */
1903
- function preventDefaultForA11yClick(eventInfo) {
1904
- if (!getA11yClickKey(eventInfo) ||
1905
- (!isSpaceKeyEvent(getEvent(eventInfo)) &&
1906
- !shouldCallPreventDefaultOnNativeHtmlControl(getEvent(eventInfo)))) {
1907
- return;
1908
- }
1909
- preventDefault(getEvent(eventInfo));
1910
- }
1911
- /**
1912
- * Sets the `action` to `clickonly` for a click event that is not an a11y click
1913
- * and if there is not already a click action.
1914
- */
1915
- function populateClickOnlyAction(actionElement, eventInfo, actionMap) {
1916
- if (
1917
- // If there's already an action, don't attempt to set a CLICKONLY
1918
- getAction(eventInfo) ||
1919
- // Only attempt CLICKONLY if the type is CLICK
1920
- getEventType(eventInfo) !== EventType.CLICK ||
1921
- // a11y clicks are never CLICKONLY
1922
- getA11yClickKey(eventInfo) ||
1923
- actionMap[EventType.CLICKONLY] === undefined) {
1924
- return;
1925
- }
1926
- setEventType(eventInfo, EventType.CLICKONLY);
1927
- setAction(eventInfo, actionMap[EventType.CLICKONLY], actionElement);
1928
- }
1929
-
1930
1800
  /**
1931
1801
  * @define Support for accessible click actions. This flag can be overridden in
1932
1802
  * a build rule.
@@ -1938,29 +1808,6 @@ const A11Y_CLICK_SUPPORT = false;
1938
1808
  */
1939
1809
  const MOUSE_SPECIAL_SUPPORT = false;
1940
1810
 
1941
- /**
1942
- * @fileoverview Implements the local event handling contract. This
1943
- * allows DOM objects in a container that enters into this contract to
1944
- * define event handlers which are executed in a local context.
1945
- *
1946
- * One EventContract instance can manage the contract for multiple
1947
- * containers, which are added using the addContainer() method.
1948
- *
1949
- * Events can be registered using the addEvent() method.
1950
- *
1951
- * A Dispatcher is added using the registerDispatcher() method. Until there is
1952
- * a dispatcher, events are queued. The idea is that the EventContract
1953
- * class is inlined in the HTML of the top level page and instantiated
1954
- * right after the start of <body>. The Dispatcher class is contained
1955
- * in the external deferred js, and instantiated and registered with
1956
- * EventContract when the external javascript in the page loads. The
1957
- * external javascript will also register the jsaction handlers, which
1958
- * then pick up the queued events at the time of registration.
1959
- *
1960
- * Since this class is meant to be inlined in the main page HTML, the
1961
- * size of the binary compiled from this file MUST be kept as small as
1962
- * possible and thus its dependencies to a minimum.
1963
- */
1964
1811
  /**
1965
1812
  * EventContract intercepts events in the bubbling phase at the
1966
1813
  * boundary of a container element, and maps them to generic actions
@@ -2002,18 +1849,7 @@ class EventContract {
2002
1849
  * as soon as the `Dispatcher` is registered.
2003
1850
  */
2004
1851
  this.queuedEventInfos = [];
2005
- /** Whether to add an a11y click listener. */
2006
- this.addA11yClickListener = false;
2007
1852
  this.containerManager = containerManager;
2008
- if (this.useActionResolver) {
2009
- this.actionResolver = new ActionResolver({
2010
- syntheticMouseEventSupport: EventContract.MOUSE_SPECIAL_SUPPORT,
2011
- });
2012
- }
2013
- if (EventContract.A11Y_CLICK_SUPPORT) {
2014
- // Add a11y click support to the `EventContract`.
2015
- this.addA11yClickSupport();
2016
- }
2017
1853
  }
2018
1854
  handleEvent(eventType, event, container) {
2019
1855
  const eventInfo = createEventInfoFromParameters(
@@ -2034,10 +1870,6 @@ class EventContract {
2034
1870
  this.queuedEventInfos?.push(eventInfo);
2035
1871
  return;
2036
1872
  }
2037
- if (this.useActionResolver) {
2038
- this.actionResolver.resolveEventType(eventInfo);
2039
- this.actionResolver.resolveAction(eventInfo);
2040
- }
2041
1873
  this.dispatcher(eventInfo);
2042
1874
  }
2043
1875
  /**
@@ -2076,11 +1908,6 @@ class EventContract {
2076
1908
  eventHandler(eventType, event, element);
2077
1909
  };
2078
1910
  });
2079
- // Automatically install a keypress/keydown event handler if support for
2080
- // accessible clicks is turned on.
2081
- if (this.addA11yClickListener && eventType === EventType.CLICK) {
2082
- this.addEvent(EventType.KEYDOWN);
2083
- }
2084
1911
  }
2085
1912
  /**
2086
1913
  * Gets the queued early events and replay them using the appropriate handler
@@ -2176,26 +2003,12 @@ class EventContract {
2176
2003
  * Adds a11y click support to the given `EventContract`. Meant to be called in
2177
2004
  * the same compilation unit as the `EventContract`.
2178
2005
  */
2179
- addA11yClickSupport() {
2180
- this.addA11yClickSupportImpl(updateEventInfoForA11yClick, preventDefaultForA11yClick, populateClickOnlyAction);
2181
- }
2006
+ addA11yClickSupport() { }
2182
2007
  /**
2183
2008
  * Enables a11y click support to be deferred. Meant to be called in the same
2184
2009
  * compilation unit as the `EventContract`.
2185
2010
  */
2186
- exportAddA11yClickSupport() {
2187
- this.addA11yClickListener = true;
2188
- this.ecaacs = this.addA11yClickSupportImpl.bind(this);
2189
- }
2190
- /**
2191
- * Unrenamed function that loads a11yClickSupport.
2192
- */
2193
- addA11yClickSupportImpl(updateEventInfoForA11yClick, preventDefaultForA11yClick, populateClickOnlyAction) {
2194
- this.addA11yClickListener = true;
2195
- if (this.useActionResolver) {
2196
- this.actionResolver.addA11yClickSupport(updateEventInfoForA11yClick, preventDefaultForA11yClick, populateClickOnlyAction);
2197
- }
2198
- }
2011
+ exportAddA11yClickSupport() { }
2199
2012
  }
2200
2013
  function removeEventListeners(container, eventTypes, earlyEventHandler, capture) {
2201
2014
  for (let idx = 0; idx < eventTypes.length; idx++) {
@@ -2208,9 +2021,7 @@ function removeEventListeners(container, eventTypes, earlyEventHandler, capture)
2208
2021
  * must have called `exportAddA11yClickSupport` in its compilation unit for this
2209
2022
  * to have any effect.
2210
2023
  */
2211
- function addDeferredA11yClickSupport(eventContract) {
2212
- eventContract.ecaacs?.(updateEventInfoForA11yClick, preventDefaultForA11yClick, populateClickOnlyAction);
2213
- }
2024
+ function addDeferredA11yClickSupport(eventContract) { }
2214
2025
 
2215
2026
  /**
2216
2027
  * EarlyEventContract intercepts events in the bubbling phase at the
@@ -2269,5 +2080,5 @@ function bootstrapEarlyEventContract(field, container, appId, eventTypes, captur
2269
2080
  eventContract.addEvents(captureEventTypes, true);
2270
2081
  }
2271
2082
 
2272
- export { Attribute, EventContract, EventContractContainer, EventDispatcher, EventInfoWrapper, EventPhase, JSACTION$1 as JSACTION, JSINSTANCE, JSTRACK, OI$1 as OI, VED, VET, bootstrapEarlyEventContract, isCaptureEvent, isSupportedEvent, registerDispatcher };
2083
+ export { Attribute, EventContract, EventContractContainer, EventDispatcher, EventInfoWrapper, EventPhase, bootstrapEarlyEventContract, isCaptureEvent, isSupportedEvent, registerDispatcher, registerEventType, unregisterEventType };
2273
2084
  //# sourceMappingURL=event-dispatch.mjs.map