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

Function getSyntheticLink

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

Source from the content-addressed store, hash-verified

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