Fix always-false boolean condition#38665
Merged
Conversation
battlesnake
commented
May 28, 2023
| window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => { | ||
| const storedTheme = getStoredTheme() | ||
| if (storedTheme !== 'light' || storedTheme !== 'dark') { | ||
| if (storedTheme !== 'light' && storedTheme !== 'dark') { |
Contributor
Author
There was a problem hiding this comment.
!a || !b => !(a && b) i.e. original was equivalent to !(storedTheme === 'light' && storedTheme === 'dark') which would only be true for Erwin Schrodinger.
julien-deramond
approved these changes
May 30, 2023
Member
There was a problem hiding this comment.
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 :)
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Checklist
npm run lint)Live previews
Related issues