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

Fix: "Uncaught TypeError: Cannot read property 'className' of null" #968

Merged
merged 2 commits into from
Oct 13, 2017
Merged

Fix: "Uncaught TypeError: Cannot read property 'className' of null" #968

merged 2 commits into from
Oct 13, 2017

Conversation

adrichey
Copy link
Contributor

This fixes a bug where elements without a target offsetParent were throwing uncaught errors when trying to determine if a click event originated from an info panel element or not.

let isInfoPanel = false
if (e.target.offsetParent !== null) {
isInfoPanel = e.target.offsetParent.className.includes('infoPanel')
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! However, I prefer this way

  const offsetParent = e.target.offsetParent
  const isInfoPanel = offsetParent !== null
    ? offsetParent.className.includes('infoPanel')
    : false

How about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I will update that in a bit. The only reason I did it the way I did is for readability. Ternary statement it is!

…ll" bug that appears when creating folders (coding style adjustments)
@asmsuechan asmsuechan merged commit c429fc6 into BoostIO:master Oct 13, 2017
@asmsuechan
Copy link
Contributor

Thank you so much!

@kazup01
Copy link
Member

kazup01 commented Oct 13, 2017

Thanks @adrichey !

@adrichey
Copy link
Contributor Author

Anytime! Glad to assist!

@kohei-takata kohei-takata mentioned this pull request Oct 28, 2017
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.

4 participants