MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getSyntheticLink

Function getSyntheticLink

packages/react-aria/src/utils/openLink.tsx:132–157  ·  view source on GitHub ↗
(target: Element, open: (link: HTMLAnchorElement) => void)

Source from the content-addressed store, hash-verified

130(openLink as any).isOpening = false;
131
132function getSyntheticLink(target: Element, open: (link: HTMLAnchorElement) => void) {
133 if (target instanceof HTMLAnchorElement) {
134 open(target);
135 } else if (target.hasAttribute('data-href')) {
136 let link = document.createElement('a');
137 link.href = target.getAttribute('data-href')!;
138 if (target.hasAttribute('data-target')) {
139 link.target = target.getAttribute('data-target')!;
140 }
141 if (target.hasAttribute('data-rel')) {
142 link.rel = target.getAttribute('data-rel')!;
143 }
144 if (target.hasAttribute('data-download')) {
145 link.download = target.getAttribute('data-download')!;
146 }
147 if (target.hasAttribute('data-ping')) {
148 link.ping = target.getAttribute('data-ping')!;
149 }
150 if (target.hasAttribute('data-referrer-policy')) {
151 link.referrerPolicy = target.getAttribute('data-referrer-policy')!;
152 }
153 target.appendChild(link);
154 open(link);
155 target.removeChild(link);
156 }
157}
158
159function openSyntheticLink(target: Element, modifiers: Modifiers) {
160 getSyntheticLink(target, link => openLink(link, modifiers));

Callers 2

RouterProviderFunction · 0.85
openSyntheticLinkFunction · 0.85

Calls 5

hasAttributeMethod · 0.80
createElementMethod · 0.80
appendChildMethod · 0.80
openFunction · 0.50
removeChildMethod · 0.45

Tested by

no test coverage detected