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

Function appendBefore

source/helpers/dom-utils.ts:28–40  ·  view source on GitHub ↗
(parent: string | Element, before: string, child: Node)

Source from the content-addressed store, hash-verified

26 </parent>
27 */
28export const appendBefore = (parent: string | Element, before: string, child: Node): void => {
29 if (typeof parent === 'string') {
30 parent = $(parent);
31 }
32
33 // Select direct children only
34 const beforeElement = $optional(`:scope > :is(${before})`, parent);
35 if (beforeElement) {
36 beforeElement.before(child);
37 } else {
38 parent.append(child);
39 }
40};
41
42export const wrap = (target: Element | ChildNode, wrapper: Element): void => {
43 target.before(wrapper);

Callers 2

markPrivateFunction · 0.85
addReleasesDropdownItemFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected