Skip to content

Commit 7848e3c

Browse files
committed
return early instead of erroring out on nonstandard page
1 parent 9143e5d commit 7848e3c

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

javascripts/events.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ export default function initializeEvents () {
192192
})
193193
})
194194

195+
if (!document.querySelector('.sidebar-products')) return
196+
195197
// Navigate event
196198
Array.from(
197199
document.querySelectorAll('.sidebar-products details')

javascripts/index.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,23 @@ import filterCodeExamples from './filter-code-examples'
1919
import allArticles from './all-articles'
2020
import devToc from './dev-toc'
2121

22-
if (location.pathname.endsWith('/dev-toc')) {
22+
document.addEventListener('DOMContentLoaded', async () => {
23+
displayPlatformSpecificContent()
24+
explorer()
25+
search()
26+
nav()
27+
browserDateFormatter()
28+
deprecationBanner()
29+
sidebar()
30+
wrapCodeTerms()
31+
print()
32+
localization()
33+
await fillCsrf() // this must complete before any POST calls
34+
helpfulness()
35+
experiment()
36+
copyCode()
37+
initializeEvents()
38+
filterCodeExamples()
39+
allArticles()
2340
devToc()
24-
} else {
25-
document.addEventListener('DOMContentLoaded', async () => {
26-
displayPlatformSpecificContent()
27-
explorer()
28-
search()
29-
nav()
30-
browserDateFormatter()
31-
deprecationBanner()
32-
sidebar()
33-
wrapCodeTerms()
34-
print()
35-
localization()
36-
await fillCsrf() // this must complete before any POST calls
37-
helpfulness()
38-
experiment()
39-
copyCode()
40-
initializeEvents()
41-
filterCodeExamples()
42-
allArticles()
43-
})
44-
}
41+
})

javascripts/nav.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ export default function () {
33
const hamburgerButton = document.querySelector('.nav-mobile-burgerIcon')
44
const mobileDropdown = document.querySelector('.nav-mobile-dropdown')
55

6+
if (!(hamburgerButton && mobileDropdown)) return
7+
68
hamburgerButton.addEventListener('click', (event) => {
79
event.preventDefault()
810
hamburgerButton.classList.toggle('js-open')

javascripts/search.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const resultTemplate = (item) => {
6363
}
6464

6565
export default function () {
66+
if (!document.querySelector('#search-results-container')) return
67+
6668
window.initialPageLoad = true
6769
const opts = {
6870

0 commit comments

Comments
 (0)