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

[Bug] referenceButtons creates errors when undefined #183

Closed
AmasiaNalbandian opened this issue Feb 2, 2022 · 1 comment
Closed

[Bug] referenceButtons creates errors when undefined #183

AmasiaNalbandian opened this issue Feb 2, 2022 · 1 comment

Comments

@AmasiaNalbandian
Copy link

Version

BS5

Reproduction link

Seneca-CDOT/telescope#2691

Operating System

Windows/OS

Device

PC

Browser & Version

Chrome Version 97.0.4692.99

Steps to reproduce

ReferenceButtons is not always defined, See

if (referenceButtons.classList.contains('active') && referenceButtons.getAttribute('data-class') === 'bg-transparent') {
.

We should protect this.

What is expected?

There should not be any errors in console due to undefined variables.

What is actually happening?

Error in console:
Uncaught TypeError: Cannot read properties of null (reading 'classList') at 'navbarColorOnResize.


Solution

use optional chaining as below:
if (referenceButtons?.classList.contains('active') && referenceButtons?.getAttribute('data-class') === 'bg-transparent') {

Additional comments

I'd be happy to contribute the fix for this.

@groovemen
Copy link
Contributor

Hello @AmasiaNalbandian,

Thank you for using our products and for your solution to this issue. We are preparing an upgrade for this product this week, so if you want to contribute, please create a PR or we will integrate your solution in this next update.
Please let us know if we can help you with anything else.
All the best,
Stefan

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

No branches or pull requests

2 participants