File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import requestIdleCallback from './request-idle-callback.mjs';
19
19
20
20
const toPrefetch = new Set ( ) ;
21
21
22
- const observer = new IntersectionObserver ( entries => {
22
+ const observer = window . IntersectionObserver && new IntersectionObserver ( entries => {
23
23
entries . forEach ( entry => {
24
24
if ( entry . isIntersecting ) {
25
25
const link = entry . target ;
@@ -74,7 +74,7 @@ function isIgnored(node, filter) {
74
74
export default function ( options ) {
75
75
if ( ! options ) options = { } ;
76
76
77
- observer . priority = options . priority || false ;
77
+ observer && ( observer . priority = options . priority || false ) ;
78
78
79
79
const allowed = options . origins || [ location . hostname ] ;
80
80
const ignores = options . ignores || [ ] ;
@@ -86,7 +86,7 @@ export default function (options) {
86
86
// If URLs are given, prefetch them.
87
87
if ( options . urls ) {
88
88
options . urls . forEach ( prefetcher ) ;
89
- } else {
89
+ } else if ( observer ) {
90
90
// If not, find all links and use IntersectionObserver.
91
91
Array . from ( ( options . el || document ) . querySelectorAll ( 'a' ) , link => {
92
92
observer . observe ( link ) ;
You can’t perform that action at this time.
0 commit comments