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

Function collectDomEventsInfo

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

Source from the content-addressed store, hash-verified

228 * LView. Maps collected events to a corresponding DOM element (an element is used as a key).
229 */
230export function collectDomEventsInfo(
231 tView: TView,
232 lView: LView,
233 eventTypesToReplay: {regular: Set<string>; capture: Set<string>},
234): Map<Element, string[]> {
235 const domEventsInfo = new Map<Element, string[]>();
236 const lCleanup = lView[CLEANUP];
237 const tCleanup = tView.cleanup;
238 if (!tCleanup || !lCleanup) {
239 return domEventsInfo;
240 }
241 for (let i = 0; i < tCleanup.length; ) {
242 const firstParam = tCleanup[i++];
243 const secondParam = tCleanup[i++];
244 if (typeof firstParam !== 'string') {
245 continue;
246 }
247 const eventType = firstParam;
248 if (!isEarlyEventType(eventType)) {
249 continue;
250 }
251 if (isCaptureEventType(eventType)) {
252 eventTypesToReplay.capture.add(eventType);
253 } else {
254 eventTypesToReplay.regular.add(eventType);
255 }
256 const listenerElement = unwrapRNode(lView[secondParam]) as any as Element;
257 i++; // move the cursor to the next position (location of the listener idx)
258 const useCaptureOrIndx = tCleanup[i++];
259 // if useCaptureOrIndx is boolean then report it as is.
260 // if useCaptureOrIndx is positive number then it in unsubscribe method
261 // if useCaptureOrIndx is negative number then it is a Subscription
262 const isDomEvent = typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0;
263 if (!isDomEvent) {
264 continue;
265 }
266 if (!domEventsInfo.has(listenerElement)) {
267 domEventsInfo.set(listenerElement, [eventType]);
268 } else {
269 domEventsInfo.get(listenerElement)!.push(eventType);
270 }
271 }
272 return domEventsInfo;
273}
274
275export function invokeRegisteredReplayListeners(
276 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