MCPcopy
hub / github.com/ChromeDevTools/chrome-devtools-mcp / createExtraNode

Method createExtraNode

src/TextSnapshot.ts:166–199  ·  view source on GitHub ↗
(
      handle: ElementHandle,
    )

Source from the content-addressed store, hash-verified

164 const {uniqueBackendNodeIdToMcpId} = page;
165
166 const createExtraNode = async (
167 handle: ElementHandle,
168 ): Promise<TextSnapshotNode | null> => {
169 const backendNodeId = await handle.backendNodeId();
170 if (!backendNodeId || seenBackendNodeIds.has(backendNodeId)) {
171 return null;
172 }
173 const uniqueBackendId = `custom_${backendNodeId}`;
174 if (seenUniqueIds.has(uniqueBackendId)) {
175 return null;
176 }
177 seenBackendNodeIds.add(backendNodeId);
178
179 let id = '';
180 const mcpId = uniqueBackendNodeIdToMcpId.get(uniqueBackendId);
181 if (mcpId !== undefined) {
182 id = mcpId;
183 } else {
184 id = `${snapshotId}_${idCounter++}`;
185 uniqueBackendNodeIdToMcpId.set(uniqueBackendId, id);
186 }
187 seenUniqueIds.add(uniqueBackendId);
188
189 const tagHandle = await handle.getProperty('localName');
190 const tagValue = await tagHandle.jsonValue();
191 const extraNode: TextSnapshotNode = {
192 role: tagValue,
193 id,
194 backendNodeId,
195 children: [],
196 elementHandle: async () => handle,
197 };
198 return extraNode;
199 };
200
201 const findAncestorNode = async (
202 handle: ElementHandle,

Callers

nothing calls this directly

Calls 3

hasMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected