File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,14 +42,14 @@ function prefetcher(url) {
4242 * @param {Object } options - Configuration options for quicklink
4343 * @param {Array } options.urls - Array of URLs to prefetch (override)
4444 * @param {Object } options.el - DOM element to prefetch in-viewport links of
45- * @param {string } options.priority - Attempt to fetch with higher priority (low or high)
45+ * @param {Boolean } options.priority - Attempt higher priority fetch (low or high)
4646 * @param {Number } options.timeout - Timeout after which prefetching will occur
4747 * @param {function } options.timeoutFn - Custom timeout function
4848 */
4949export default function ( options ) {
5050 options = Object . assign ( {
51- priority : 'low' ,
5251 timeout : 2e3 ,
52+ priority : false ,
5353 timeoutFn : requestIdleCallback ,
5454 el : document ,
5555 } , options ) ;
Original file line number Diff line number Diff line change @@ -113,11 +113,11 @@ const supportedPrefetchStrategy = support(`prefetch`)
113113
114114/**
115115 * Prefetch a given URL with an optional preferred fetch priority
116- * @param {string } url - the URL to fetch
117- * @param {string } priority - preferred fetch priority (`low` or ` high`)
116+ * @param {String } url - the URL to fetch
117+ * @param {Boolean } isPriority - if is " high" priority
118118 * @return {Object } a Promise
119119 */
120- async function prefetcher ( url , priority ) {
120+ async function prefetcher ( url , isPriority ) {
121121 if ( preFetched [ url ] ) {
122122 return ;
123123 }
@@ -134,11 +134,7 @@ async function prefetcher(url, priority) {
134134 }
135135
136136 try {
137- if ( priority && priority === `high` ) {
138- await highPriFetchStrategy ( url ) ;
139- } else {
140- await supportedPrefetchStrategy ( url ) ;
141- } ;
137+ await ( isPriority ? highPriFetchStrategy : supportedPrefetchStrategy ) ( url ) ;
142138 preFetched [ url ] = true ;
143139 } catch ( e ) {
144140 // Wanna do something?
You can’t perform that action at this time.
0 commit comments