MCPcopy
hub / github.com/adobe/react-spectrum / createShadowRoot

Function createShadowRoot

packages/dev/test-utils/src/shadowDOM.ts:19–25  ·  view source on GitHub ↗
(attachTo: HTMLElement = document.body)

Source from the content-addressed store, hash-verified

17}
18
19export function createShadowRoot(attachTo: HTMLElement = document.body): ShadowRootReturnValue {
20 const div = document.createElement('div');
21 div.setAttribute('data-testid', 'shadow-root');
22 attachTo.appendChild(div);
23 const shadowRoot = div.attachShadow({mode: 'open'});
24 return {shadowHost: div, shadowRoot, cleanup: () => attachTo.removeChild(div)};
25}

Callers 7

setupShadowDOMTestFunction · 0.85
useFocus.test.jsFile · 0.85
FocusScope.test.jsFile · 0.85

Calls 4

createElementMethod · 0.80
setAttributeMethod · 0.80
appendChildMethod · 0.80
removeChildMethod · 0.45

Tested by 1

setupShadowDOMTestFunction · 0.68