elMatchesStrategy() — astro Function Reference
Architecture documentation for the elMatchesStrategy() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 70bfc884_b3b0_e84b_4b73_06d369aade2b["elMatchesStrategy()"] 315e53ea_6d34_137c_ce5c_8c89aca90db9["index.ts"] 70bfc884_b3b0_e84b_4b73_06d369aade2b -->|defined in| 315e53ea_6d34_137c_ce5c_8c89aca90db9 24714cbf_c269_c51b_a951_fe6138916c1c["initTapStrategy()"] 24714cbf_c269_c51b_a951_fe6138916c1c -->|calls| 70bfc884_b3b0_e84b_4b73_06d369aade2b 90b6d96b_d7f2_cf1e_695c_fcf15d5c6440["initHoverStrategy()"] 90b6d96b_d7f2_cf1e_695c_fcf15d5c6440 -->|calls| 70bfc884_b3b0_e84b_4b73_06d369aade2b 8c99d8e4_b1d5_84e4_ba47_c797c9e87ba9["initViewportStrategy()"] 8c99d8e4_b1d5_84e4_ba47_c797c9e87ba9 -->|calls| 70bfc884_b3b0_e84b_4b73_06d369aade2b f350ee51_b3bd_e845_7222_24e2d4d0756a["initLoadStrategy()"] f350ee51_b3bd_e845_7222_24e2d4d0756a -->|calls| 70bfc884_b3b0_e84b_4b73_06d369aade2b fa17c239_9e46_24a4_170f_6c1482c21778["isSlowConnection()"] 70bfc884_b3b0_e84b_4b73_06d369aade2b -->|calls| fa17c239_9e46_24a4_170f_6c1482c21778 style 70bfc884_b3b0_e84b_4b73_06d369aade2b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/prefetch/index.ts lines 267–293
function elMatchesStrategy(el: EventTarget | null, strategy: string): el is HTMLAnchorElement {
// @ts-expect-error access unknown property this way as it's more performant
if (el?.tagName !== 'A') return false;
const attrValue = (el as HTMLElement).dataset.astroPrefetch;
// Out-out if `prefetchAll` is enabled
if (attrValue === 'false') {
return false;
}
// Fallback to tap strategy if using data saver mode or slow connection
if (strategy === 'tap' && (attrValue != null || prefetchAll) && isSlowConnection()) {
return true;
}
// If anchor has no dataset but we want to prefetch all, or has dataset but no value,
// check against fallback default strategy
if ((attrValue == null && prefetchAll) || attrValue === '') {
return strategy === defaultStrategy;
}
// Else if dataset is explicitly defined, check against it
if (attrValue === strategy) {
return true;
}
// Else, no match
return false;
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does elMatchesStrategy() do?
elMatchesStrategy() is a function in the astro codebase, defined in packages/astro/src/prefetch/index.ts.
Where is elMatchesStrategy() defined?
elMatchesStrategy() is defined in packages/astro/src/prefetch/index.ts at line 267.
What does elMatchesStrategy() call?
elMatchesStrategy() calls 1 function(s): isSlowConnection.
What calls elMatchesStrategy()?
elMatchesStrategy() is called by 4 function(s): initHoverStrategy, initLoadStrategy, initTapStrategy, initViewportStrategy.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free