MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / formatNode

Function formatNode

lib/aria.js:133–149  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

131
132// One-line representation of a node. Stable attr order so diff comparisons are deterministic.
133function formatNode(node) {
134 let line = node.role
135 if (node.name && node.name.trim()) line += ` "${node.name.trim()}"`
136 const attrParts = []
137 for (const k of Object.keys(node.attributes).sort()) {
138 const v = node.attributes[k]
139 if (v === undefined || v === null || v === '') continue
140 if (v === true) attrParts.push(k)
141 else attrParts.push(`${k}=${v}`)
142 }
143 if (attrParts.length > 0) line += ` [${attrParts.join(' ')}]`
144 if (node.value !== undefined && node.value !== null) {
145 const text = String(node.value).trim()
146 if (text) line += `: ${text}`
147 }
148 return line
149}
150
151// Group consecutive same-role siblings. [a,a,b,a,a,a] → [[a,a],[b],[a,a,a]]
152function groupByConsecutiveRole(nodes) {

Callers 2

renderTreeFunction · 0.85
collectSummariesFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected