MCPcopy Create free account
hub / github.com/angular/angular / collectDomEventsInfo

Function collectDomEventsInfo

packages/core/src/hydration/event_replay.ts:256–299  ·  view source on GitHub ↗
(
  tView: TView,
  lView: LView,
  eventTypesToReplay: {regular: Set<string>; capture: Set<string>},
)

Source from the content-addressed store, hash-verified

254 * LView. Maps collected events to a corresponding DOM element (an element is used as a key).
255 */
256export function collectDomEventsInfo(
257 tView: TView,
258 lView: LView,
259 eventTypesToReplay: {regular: Set<string>; capture: Set<string>},
260): Map<Element, string[]> {
261 const domEventsInfo = new Map<Element, string[]>();
262 const lCleanup = lView[CLEANUP];
263 const tCleanup = tView.cleanup;
264 if (!tCleanup || !lCleanup) {
265 return domEventsInfo;
266 }
267 for (let i = 0; i < tCleanup.length;) {
268 const firstParam = tCleanup[i++];
269 const secondParam = tCleanup[i++];
270 if (typeof firstParam !== 'string') {
271 continue;
272 }
273 const eventType = firstParam;
274 if (!isEarlyEventType(eventType)) {
275 continue;
276 }
277 if (isCaptureEventType(eventType)) {
278 eventTypesToReplay.capture.add(eventType);
279 } else {
280 eventTypesToReplay.regular.add(eventType);
281 }
282 const listenerElement = unwrapRNode(lView[secondParam]) as any as Element;
283 i++; // move the cursor to the next position (location of the listener idx)
284 const useCaptureOrIndx = tCleanup[i++];
285 // if useCaptureOrIndx is boolean then report it as is.
286 // if useCaptureOrIndx is positive number then it in unsubscribe method
287 // if useCaptureOrIndx is negative number then it is a Subscription
288 const isDomEvent = typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0;
289 if (!isDomEvent) {
290 continue;
291 }
292 if (!domEventsInfo.has(listenerElement)) {
293 domEventsInfo.set(listenerElement, [eventType]);
294 } else {
295 domEventsInfo.get(listenerElement)!.push(eventType);
296 }
297 }
298 return domEventsInfo;
299}
300
301export function invokeRegisteredReplayListeners(
302 injector: Injector,

Callers 1

serializeLViewFunction · 0.90

Calls 8

isEarlyEventTypeFunction · 0.90
isCaptureEventTypeFunction · 0.90
unwrapRNodeFunction · 0.90
addMethod · 0.65
hasMethod · 0.65
setMethod · 0.65
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected