MCPcopy
hub / github.com/vuejs/core / hydrateOnInteraction

Function hydrateOnInteraction

packages/runtime-core/src/hydrationStrategies.ts:85–111  ·  view source on GitHub ↗
(interactions = [])

Source from the content-addressed store, hash-verified

83 keyof HTMLElementEventMap | Array<keyof HTMLElementEventMap>
84> =
85 (interactions = []) =>
86 (hydrate, forEach) => {
87 if (isString(interactions)) interactions = [interactions]
88 let hasHydrated = false
89 const doHydrate = (e: Event) => {
90 if (!hasHydrated) {
91 hasHydrated = true
92 teardown()
93 hydrate()
94 // replay event
95 e.target!.dispatchEvent(new (e.constructor as any)(e.type, e))
96 }
97 }
98 const teardown = () => {
99 forEach(el => {
100 for (const i of interactions) {
101 el.removeEventListener(i, doHydrate)
102 }
103 })
104 }
105 forEach(el => {
106 for (const i of interactions) {
107 el.addEventListener(i, doHydrate, { once: true })
108 }
109 })
110 return teardown
111 }
112
113export function forEachElement(
114 node: Node,

Callers

nothing calls this directly

Calls 2

isStringFunction · 0.90
forEachFunction · 0.50

Tested by

no test coverage detected