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

Function forEachElement

packages/runtime-core/src/hydrationStrategies.ts:113–139  ·  view source on GitHub ↗
(
  node: Node,
  cb: (el: Element) => void | false,
)

Source from the content-addressed store, hash-verified

111 }
112
113export function forEachElement(
114 node: Node,
115 cb: (el: Element) => void | false,
116): void {
117 // fragment
118 if (isComment(node) && node.data === '[') {
119 let depth = 1
120 let next = node.nextSibling
121 while (next) {
122 if (next.nodeType === DOMNodeTypes.ELEMENT) {
123 const result = cb(next as Element)
124 if (result === false) {
125 break
126 }
127 } else if (isComment(next)) {
128 if (next.data === ']') {
129 if (--depth === 0) break
130 } else if (next.data === '[') {
131 depth++
132 }
133 }
134 next = next.nextSibling
135 }
136 } else {
137 cb(node as Element)
138 }
139}

Callers 1

__asyncHydrateFunction · 0.90

Calls 2

isCommentFunction · 0.90
cbFunction · 0.85

Tested by

no test coverage detected