MCPcopy Index your code
hub / github.com/refined-github/refined-github / attachElement

Function attachElement

source/helpers/attach-element.ts:15–42  ·  view source on GitHub ↗
(
	anchor: Element | undefined,
	{
		before,
		after,
	}: Attachment<NewElement>,
)

Source from the content-addressed store, hash-verified

13}, Position>;
14
15export default function attachElement<NewElement extends Element>(
16 anchor: Element | undefined,
17 {
18 before,
19 after,
20 }: Attachment<NewElement>,
21): void {
22 if (!anchor) {
23 throw new Error('Element not found');
24 }
25
26 const className = 'rgh-attached-' + getCallerId();
27 if (elementExists('.' + className, anchor.parentElement!)) {
28 return;
29 }
30
31 if (before) {
32 const element = before(anchor);
33 element.classList.add(className);
34 anchor.before(element);
35 }
36
37 if (after) {
38 const element = after(anchor);
39 element.classList.add(className);
40 anchor.after(element);
41 }
42}

Callers 4

appendNameFunction · 0.85
clearFunction · 0.85
initFunction · 0.85
initFunction · 0.85

Calls 1

getCallerIdFunction · 0.85

Tested by

no test coverage detected