Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure element exists before access it #356

Merged
merged 2 commits into from
Aug 3, 2022
Merged

Conversation

yshrsmz
Copy link
Contributor

@yshrsmz yshrsmz commented Jul 27, 2022

I got the following error when I created a layout without a header.

Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
    at main.min.js:1:2293
    at Array.forEach (<anonymous>)
    at HTMLDocument.<anonymous> (main.min.js:1:2271)
Uncaught TypeError: Cannot set properties of null (setting 'innerHTML')
    at setMode (main.min.js:1:1492)
    at window.onload (main.min.js:1:1803)

so added null checks to ensure that we use these elements when it actually exists.

assets/js/partials/navbar.js Show resolved Hide resolved
assets/js/partials/navbar.js Show resolved Hide resolved
@yshrsmz yshrsmz requested a review from sylhare August 3, 2022 10:31
@sylhare sylhare merged commit 1ba7d8d into sylhare:master Aug 3, 2022
@yshrsmz yshrsmz deleted the null-check branch August 4, 2022 02:24
@yshrsmz
Copy link
Contributor Author

yshrsmz commented Aug 4, 2022

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants