Skip to content

Commit ac48837

Browse files
committed
Always react on color scheme changes, even when permanent is set
1 parent 30c699e commit ac48837

File tree

3 files changed

+84
-101
lines changed

3 files changed

+84
-101
lines changed

package-lock.json

+78-93
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dark-mode-toggle",
3-
"version": "0.4.9",
3+
"version": "0.4.10",
44
"description": "Web Component that toggles dark mode 🌒",
55
"main": "./src/dark-mode-toggle.mjs",
66
"browser": "src/dark-mode-toggle.mjs",
@@ -38,9 +38,9 @@
3838
"eslint-config-google": "^0.14.0",
3939
"http-server": "^0.11.1",
4040
"shx": "^0.3.2",
41-
"stylelint": "^11.0.0",
41+
"stylelint": "^11.1.1",
4242
"stylelint-config-standard": "^19.0.0",
43-
"terser": "^4.3.4"
43+
"terser": "^4.3.9"
4444
},
4545
"eslintConfig": {
4646
"parserOptions": {

src/dark-mode-toggle.mjs

+3-5
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,11 @@ export class DarkModeToggle extends HTMLElement {
135135
// Does the browser support native `prefers-color-scheme`?
136136
const hasNativePrefersColorScheme =
137137
matchMedia(MQ_DARK).media !== NOT_ALL;
138-
// Listen to `prefers-color-scheme` changes, unless `permanent` is true.
138+
// Listen to `prefers-color-scheme` changes.
139139
if (hasNativePrefersColorScheme) {
140140
matchMedia(MQ_DARK).addListener(({matches}) => {
141-
if (!this.permanent) {
142-
this.mode = matches ? DARK : LIGHT;
143-
this._dispatchEvent(COLOR_SCHEME_CHANGE, {colorScheme: this.mode});
144-
}
141+
this.mode = matches ? DARK : LIGHT;
142+
this._dispatchEvent(COLOR_SCHEME_CHANGE, {colorScheme: this.mode});
145143
});
146144
}
147145
// Set initial state, giving preference to a remembered value, then the

0 commit comments

Comments
 (0)