(element: Element, instance: PrefetchableInstance)
| 116 | : null |
| 117 | |
| 118 | function observeVisibility(element: Element, instance: PrefetchableInstance) { |
| 119 | const existingInstance = prefetchable.get(element) |
| 120 | if (existingInstance !== undefined) { |
| 121 | // This shouldn't happen because each <Link> component should have its own |
| 122 | // anchor tag instance, but it's defensive coding to avoid a memory leak in |
| 123 | // case there's a logical error somewhere else. |
| 124 | unmountPrefetchableInstance(element) |
| 125 | } |
| 126 | // Only track prefetchable links that have a valid prefetch URL |
| 127 | prefetchable.set(element, instance) |
| 128 | if (observer !== null) { |
| 129 | observer.observe(element) |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | function coercePrefetchableUrl(href: string): URL | null { |
| 134 | if (typeof window !== 'undefined') { |
no test coverage detected