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

Function getSyntheticLink

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

Source from the content-addressed store, hash-verified

147(openLink as any).isOpening = false;
148
149function getSyntheticLink(target: Element, open: (link: HTMLAnchorElement) => void) {
150 if (target instanceof HTMLAnchorElement) {
151 open(target);
152 } else if (target.hasAttribute('data-href')) {
153 let link = document.createElement('a');
154 link.href = target.getAttribute('data-href')!;
155 if (target.hasAttribute('data-target')) {
156 link.target = target.getAttribute('data-target')!;
157 }
158 if (target.hasAttribute('data-rel')) {
159 link.rel = target.getAttribute('data-rel')!;
160 }
161 if (target.hasAttribute('data-download')) {
162 link.download = target.getAttribute('data-download')!;
163 }
164 if (target.hasAttribute('data-ping')) {
165 link.ping = target.getAttribute('data-ping')!;
166 }
167 if (target.hasAttribute('data-referrer-policy')) {
168 link.referrerPolicy = target.getAttribute('data-referrer-policy')!;
169 }
170 target.appendChild(link);
171 open(link);
172 target.removeChild(link);
173 }
174}
175
176function openSyntheticLink(target: Element, modifiers: Modifiers) {
177 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