help.html: add null check
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 25 Sep 2022 20:56:32 +0000 (13:56 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 25 Sep 2022 20:56:32 +0000 (13:56 -0700)
basis/help/html/html.factor
extra/webapps/help/search.js

index ce4c206eaca45d8872154eb498ebbbfbe04bd7d3..fd258fe2d696ce2539205a380511b4dbd9ca497a 100644 (file)
@@ -97,11 +97,13 @@ M: pathname url-of
         document.addEventListener('keydown', function (event) {
             if (event.code == 'Slash') {
                 let input = document.getElementById('search');
-                if (input !== document.activeElement) {
-                    event.preventDefault();
-                    setTimeout(function() {
-                        input.focus().select()
-                    }, 0);
+                if (input != null) {
+                    if input !== document.activeElement) {
+                        event.preventDefault();
+                        setTimeout(function() {
+                            input.focus().select()
+                        }, 0);
+                    }
                 }
             }
         });
index db99569fc4e834bd9bccfa455f364855936f3ec2..7ad98c8160029921fa82409d1b6e4c244e50e408 100644 (file)
@@ -8,11 +8,13 @@ window.onload = function() {
 document.addEventListener('keydown', function (event) {
     if (event.code == 'Slash') {
         let input = document.getElementById('search');
-        if (input !== document.activeElement) {
-            event.preventDefault();
-            setTimeout(function() {
-                input.focus().select()
-            }, 0);
+        if (input != null) {
+            if (input !== document.activeElement) {
+                event.preventDefault();
+                setTimeout(function() {
+                    input.focus().select()
+                }, 0);
+            }
         }
     }
 });