DEV: Ensure core initializers with .reopen are only called once

This commit is contained in:
David Taylor 2021-10-27 16:23:48 +01:00
parent 0bec323204
commit cc18a5439c
4 changed files with 31 additions and 1 deletions

View File

@ -1,9 +1,15 @@
let initializedOnce = false;
export default {
name: "ember-events",
initialize: function () {
// By default Ember listens to too many events. This tells it the only events
// we're interested in.
// we're interested in. (it removes mousemove and touchmove)
if (initializedOnce) {
return;
}
Ember.EventDispatcher.reopen({
events: {
touchstart: "touchStart",
@ -33,5 +39,7 @@ export default {
dragend: "dragEnd",
},
});
initializedOnce = true;
},
};

View File

@ -1,15 +1,22 @@
import TextField from "@ember/component/text-field";
import TextArea from "@ember/component/text-area";
let initializedOnce = false;
export default {
name: "ember-input-component-extensions",
initialize() {
if (initializedOnce) {
return;
}
TextField.reopen({
attributeBindings: ["aria-describedby", "aria-invalid"],
});
TextArea.reopen({
attributeBindings: ["aria-describedby", "aria-invalid"],
});
initializedOnce = true;
},
};

View File

@ -1,9 +1,17 @@
let initializedOnce = false;
export default {
name: "ember-link-component-extensions",
initialize() {
if (initializedOnce) {
return;
}
Ember.LinkComponent.reopen({
attributeBindings: ["name"],
});
initializedOnce = true;
},
};

View File

@ -1,11 +1,16 @@
import LogsNotice from "discourse/services/logs-notice";
import Singleton from "discourse/mixins/singleton";
let initializedOnce = false;
export default {
name: "logs-notice",
after: "message-bus",
initialize: function (container) {
if (initializedOnce) {
return;
}
const siteSettings = container.lookup("site-settings:main");
const messageBus = container.lookup("message-bus:main");
const keyValueStore = container.lookup("key-value-store:main");
@ -20,5 +25,7 @@ export default {
});
},
});
initializedOnce = true;
},
};