DEV: Fix some js deprecations (#28915)
1. `MediaQueryList.addListener` is deprecated in favor of `addEventListener` 2. `HTMLStyleElement.type` is deprecated with no replacement
This commit is contained in:
parent
d7293eafef
commit
8a57e50664
|
@ -94,7 +94,7 @@ export default class AceEditor extends Component {
|
|||
this.appEvents.on("ace:resize", this.resize);
|
||||
window.addEventListener("resize", this.resize);
|
||||
this._darkModeListener = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
this._darkModeListener.addListener(this.setAceTheme);
|
||||
this._darkModeListener.addEventListener("change", this.setAceTheme);
|
||||
}
|
||||
|
||||
willDestroy() {
|
||||
|
@ -102,7 +102,7 @@ export default class AceEditor extends Component {
|
|||
|
||||
this.editor?.destroy();
|
||||
|
||||
this._darkModeListener?.removeListener(this.setAceTheme);
|
||||
this._darkModeListener?.removeEventListener("change", this.setAceTheme);
|
||||
window.removeEventListener("resize", this.resize);
|
||||
this.appEvents.off("ace:resize", this.resize);
|
||||
}
|
||||
|
|
|
@ -12,11 +12,8 @@ export default {
|
|||
* with the hashtag type via api.registerHashtagType. The default
|
||||
* ones in core are CategoryHashtagType and TagHashtagType.
|
||||
*/
|
||||
initialize(owner) {
|
||||
this.site = owner.lookup("service:site");
|
||||
|
||||
initialize() {
|
||||
const cssTag = document.createElement("style");
|
||||
cssTag.type = "text/css";
|
||||
cssTag.id = "hashtag-css-generator";
|
||||
cssTag.innerHTML = Object.values(getHashtagTypeClasses())
|
||||
.map((hashtagType) => hashtagType.generatePreloadedCssClasses())
|
||||
|
|
|
@ -10,10 +10,17 @@ export default {
|
|||
if (caps.isAppWebview) {
|
||||
window
|
||||
.matchMedia("(prefers-color-scheme: dark)")
|
||||
.addListener(this.updateAppBackground);
|
||||
.addEventListener("change", this.updateAppBackground);
|
||||
this.updateAppBackground();
|
||||
}
|
||||
},
|
||||
|
||||
teardown() {
|
||||
window
|
||||
.matchMedia("(prefers-color-scheme: dark)")
|
||||
.removeEventListener("change", this.updateAppBackground);
|
||||
},
|
||||
|
||||
updateAppBackground() {
|
||||
discourseLater(() => {
|
||||
const header = document.querySelector(".d-header-wrap .d-header");
|
||||
|
|
Loading…
Reference in New Issue