DEV: prevents global-notice events to leak (#7732)

This commit is contained in:
Joffrey JAFFEUX 2019-06-07 16:49:59 +02:00 committed by GitHub
parent 55325679ac
commit dfb66334c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,18 +87,36 @@ export default Ember.Component.extend(
@on("didInsertElement")
_setupLogsNotice() {
LogsNotice.current().addObserver("hidden", () => {
this.rerenderBuffer();
});
this._boundRerenderBuffer = Ember.run.bind(this, this.rerenderBuffer);
LogsNotice.current().addObserver("hidden", this._boundRerenderBuffer);
this.$().on("click.global-notice", ".alert-logs-notice .close", () => {
LogsNotice.currentProp("text", "");
});
this._boundResetCurrentProp = Ember.run.bind(
this,
this._resetCurrentProp
);
$(this.element).on(
"click.global-notice",
".alert-logs-notice .close",
this._boundResetCurrentProp
);
},
@on("willDestroyElement")
_teardownLogsNotice() {
this.$().off("click.global-notice");
if (this._boundResetCurrentProp) {
$(this.element).off("click.global-notice", this._boundResetCurrentProp);
}
if (this._boundRerenderBuffer) {
LogsNotice.current().removeObserver(
"hidden",
this._boundRerenderBuffer
);
}
},
_resetCurrentProp() {
LogsNotice.currentProp("text", "");
}
})
);