From ca06e4e35784c50371005eac0636550d1645089b Mon Sep 17 00:00:00 2001 From: Vaidehi Joshi Date: Tue, 14 Jul 2020 12:03:34 -0700 Subject: [PATCH] [deploy] Fix TypeError: Cannot set property 'innerHTML' of null (#9306) Should fix https://app.honeybadger.io/fault/67192/f79e24dfb4e4364da09dda6380e9d2ff. --- app/views/articles/_search.html.erb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/articles/_search.html.erb b/app/views/articles/_search.html.erb index 29ecaad80..2ce53f07d 100644 --- a/app/views/articles/_search.html.erb +++ b/app/views/articles/_search.html.erb @@ -16,13 +16,13 @@ var params = getQueryParams(document.location.search); - function searchMain() { + function searchMain(substories) { var query = filterXSS(params.q); var filters = filterXSS(params.filters || ""); var sortBy = filterXSS(params.sort_by || ""); var sortDirection = filterXSS(params.sort_direction || ""); - document.getElementById("substories").innerHTML = '

' + substories.innerHTML = '

'; if (document.getElementById("query-wrapper")) { search(query, filters, sortBy, sortDirection); initializeFilters(query, filters); @@ -189,8 +189,9 @@ var waitingOnSearch = setInterval(function () { if (typeof search == 'function' && typeof filterXSS == 'function' && typeof buildArticleHTML == 'function') { clearInterval(waitingOnSearch); - if (document.querySelectorAll('.search-results-loaded').length == 0) { - searchMain(); + const substories = document.getElementById("substories"); + if (document.querySelectorAll('.search-results-loaded').length == 0 && substories) { + searchMain(substories); } } }, 1);