MCPcopy Create free account
hub / github.com/benjitaylor/agentation / getFullElementPath

Function getFullElementPath

package/src/utils/element-identification.ts:586–615  ·  view source on GitHub ↗
(target: HTMLElement)

Source from the content-addressed store, hash-verified

584 * Supports elements inside shadow DOM by marking shadow boundary crossings.
585 */
586export function getFullElementPath(target: HTMLElement): string {
587 const parts: string[] = [];
588 let current: HTMLElement | null = target;
589
590 while (current && current.tagName.toLowerCase() !== "html") {
591 const tag = current.tagName.toLowerCase();
592 let identifier = tag;
593
594 if (current.id) {
595 identifier = `${tag}#${current.id}`;
596 } else if (current.className && typeof current.className === "string") {
597 const cls = current.className
598 .split(/\s+/)
599 .map(c => c.replace(/[_][a-zA-Z0-9]{5,}.*$/, ""))
600 .find(c => c.length > 2);
601 if (cls) identifier = `${tag}.${cls}`;
602 }
603
604 // Mark shadow boundary crossings
605 const nextParent = getParentElement(current);
606 if (!current.parentElement && nextParent) {
607 identifier = `⟨shadow⟩ ${identifier}`;
608 }
609
610 parts.unshift(identifier);
611 current = nextParent as HTMLElement | null;
612 }
613
614 return parts.join(" > ");
615}

Callers 3

PageFeedbackToolbarCSSFunction · 0.90
handleClickFunction · 0.90
handleMouseUpFunction · 0.90

Calls 1

getParentElementFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…