ReplyWidget: Move clear methods from #teardown to #clear

Change-Id: Ieb02f57d31579ac9c3ee2f20f07f9107e70348d4
This commit is contained in:
Ed Sanders 2020-07-08 14:07:45 +01:00
parent 0adf9f3366
commit 9b811a94e0
3 changed files with 11 additions and 11 deletions

View file

@ -210,6 +210,9 @@ ReplyWidget.prototype.clear = function () {
if ( this.errorMessage ) {
this.errorMessage.$element.remove();
}
this.$preview.empty();
this.storage.remove( this.storagePrefix + '/mode' );
this.storage.remove( this.storagePrefix + '/saveable' );
};
ReplyWidget.prototype.setPending = function ( pending ) {
@ -337,9 +340,6 @@ ReplyWidget.prototype.tryTeardown = function () {
ReplyWidget.prototype.teardown = function ( abandoned ) {
this.unbindBeforeUnloadHandler();
this.clear();
this.storage.remove( this.storagePrefix + '/mode' );
this.storage.remove( this.storagePrefix + '/saveable' );
this.$preview.empty();
this.emit( 'teardown', abandoned );
return this;
};

View file

@ -47,10 +47,12 @@ ReplyWidgetPlain.prototype.focus = function () {
};
ReplyWidgetPlain.prototype.clear = function () {
this.replyBodyWidget.setValue( '' );
this.storage.remove( this.storagePrefix + '/body' );
// Parent method
ReplyWidgetPlain.super.prototype.clear.apply( this, arguments );
this.replyBodyWidget.setValue( '' );
};
ReplyWidgetPlain.prototype.isEmpty = function () {
@ -94,8 +96,6 @@ ReplyWidgetPlain.prototype.teardown = function () {
this.replyBodyWidget.disconnect( this );
this.replyBodyWidget.off( 'change' );
this.storage.remove( this.storagePrefix + '/body' );
// Parent method
return ReplyWidgetPlain.super.prototype.teardown.call( this );
};

View file

@ -53,10 +53,12 @@ ReplyWidgetVisual.prototype.getValue = function () {
};
ReplyWidgetVisual.prototype.clear = function () {
this.replyBodyWidget.clear();
this.replyBodyWidget.target.clearDocState();
// Parent method
ReplyWidgetVisual.super.prototype.clear.apply( this, arguments );
this.replyBodyWidget.clear();
};
ReplyWidgetVisual.prototype.isEmpty = function () {
@ -111,8 +113,6 @@ ReplyWidgetVisual.prototype.setup = function ( initialValue ) {
ReplyWidgetVisual.prototype.teardown = function () {
this.replyBodyWidget.disconnect( this );
this.replyBodyWidget.off( 'change' );
// TODO: Just teardown the whole target?
this.replyBodyWidget.target.clearDocState();
// Parent method
return ReplyWidgetVisual.super.prototype.teardown.call( this );