Selaa lähdekoodia

Put `!linkElement` test in `isPreloadable`

Alexandre Dieulot 6 vuotta sitten
vanhempi
commit
d1cd031a54
1 muutettua tiedostoa jossa 4 lisäystä ja 8 poistoa
  1. 4 8
      instantpage.js

+ 4 - 8
instantpage.js

@@ -28,10 +28,6 @@ function touchstartListener(event) {
 
   const linkElement = event.target.closest('a')
 
-  if (!linkElement) {
-    return
-  }
-
   if (!isPreloadable(linkElement)) {
     return
   }
@@ -55,10 +51,6 @@ function mouseoverListener(event) {
 
   const linkElement = event.target.closest('a')
 
-  if (!linkElement) {
-    return
-  }
-
   if (!isPreloadable(linkElement)) {
     return
   }
@@ -89,6 +81,10 @@ function mouseoutListener(event) {
 }
 
 function isPreloadable(linkElement) {
+  if (!linkElement) {
+    return
+  }
+
   if (!linkElement.href) {
     return
   }