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 always-false boolean condition #38665

Merged
merged 2 commits into from
May 30, 2023
Merged

Fix always-false boolean condition #38665

merged 2 commits into from
May 30, 2023

Conversation

battlesnake
Copy link
Contributor

@battlesnake battlesnake commented May 28, 2023

Description

In the DOCS only:
I found an always-false condition while reading an example. It's for a branch that's difficult to test and will rarely get triggered (even on a global scale), so understandably hasn't been noticed yet.

Motivation & Context

In the DOCS only:
Example for color-modes / theme switcher will likely fail to handle changes in browser setting correctly, due to always-false conditional expression.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would change existing functionality)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Live previews

Related issues

@battlesnake battlesnake requested a review from a team as a code owner May 28, 2023 20:59
@@ -59,7 +59,7 @@

window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
const storedTheme = getStoredTheme()
if (storedTheme !== 'light' || storedTheme !== 'dark') {
if (storedTheme !== 'light' && storedTheme !== 'dark') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

!a || !b => !(a && b) i.e. original was equivalent to !(storedTheme === 'light' && storedTheme === 'dark') which would only be true for Erwin Schrodinger.

Copy link
Member

@julien-deramond julien-deramond left a comment

Choose a reason for hiding this comment

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

Thanks for opening this PR @battlesnake

IDK why it has finally not been included in #38626 since it was the original change, confirmed by my first tests in #38626 (comment). Maybe something forgotten while mixing both solutions :)

/cc @mdo @XhmikosR for stable 5.3.0

@XhmikosR XhmikosR added the skip-changelog So that the release drafter action doesn't include it label May 30, 2023
@XhmikosR XhmikosR merged commit ad9cb22 into twbs:main May 30, 2023
@battlesnake
Copy link
Contributor Author

Thanks, I'm actually quite surprised that such an issue was actually found live already by someone!

I just found it by analysis while translating the example to an AngularJS directive.

romankupchak93 pushed a commit to romankupchak93/bootstrap that referenced this pull request Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
color mode docs skip-changelog So that the release drafter action doesn't include it v5
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants