Explorar o código

Put `!linkElement` test in `isPreloadable`

Alexandre Dieulot %!s(int64=6) %!d(string=hai) anos
pai
achega
d1cd031a54
Modificáronse 1 ficheiros con 4 adicións e 8 borrados
  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
   }