MCPcopy
hub / github.com/vercel/next.js / observeVisibility

Function observeVisibility

packages/next/src/client/components/links.ts:118–131  ·  view source on GitHub ↗
(element: Element, instance: PrefetchableInstance)

Source from the content-addressed store, hash-verified

116 : null
117
118function 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
133function coercePrefetchableUrl(href: string): URL | null {
134 if (typeof window !== 'undefined') {

Callers 2

mountLinkInstanceFunction · 0.85
mountFormInstanceFunction · 0.85

Calls 3

getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected