MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / getTargetElement

Function getTargetElement

src/pages/markdownPreview/index.js:51–63  ·  view source on GitHub ↗
(container, targetId)

Source from the content-addressed store, hash-verified

49}
50
51function getTargetElement(container, targetId) {
52 const decodedId = decodeURIComponent(targetId || "");
53 if (!decodedId) return null;
54
55 const elements = container.querySelectorAll("[id], [name]");
56 return (
57 Array.from(elements).find(
58 (element) =>
59 element.getAttribute("id") === decodedId ||
60 element.getAttribute("name") === decodedId,
61 ) || null
62 );
63}
64
65function getOffsetTopWithinContainer(target, container) {
66 let top = 0;

Callers 1

scrollToHashFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected