ReplyLinksController: Update teardown code

Follow-up to de4d4bfb21.

Change-Id: Ibc3293a43befbbb0af400b197993135d4492fe35
This commit is contained in:
Bartosz Dziewoński 2021-11-05 20:20:42 +01:00
parent 22f48be13b
commit 578be2f91e

View file

@ -2,6 +2,7 @@ var
// Data::getLocalData() // Data::getLocalData()
parserData = require( './parser/data.json' ), parserData = require( './parser/data.json' ),
utils = require( './utils.js' ); utils = require( './utils.js' );
var featuresEnabled = mw.config.get( 'wgDiscussionToolsFeaturesEnabled' ) || {};
function ReplyLinksController( $pageContainer ) { function ReplyLinksController( $pageContainer ) {
// Mixin constructors // Mixin constructors
@ -18,7 +19,6 @@ function ReplyLinksController( $pageContainer ) {
this.$replyLinks.on( 'click keypress', this.onReplyLinkClickHandler ); this.$replyLinks.on( 'click keypress', this.onReplyLinkClickHandler );
// "Add topic" link in the skin interface // "Add topic" link in the skin interface
var featuresEnabled = mw.config.get( 'wgDiscussionToolsFeaturesEnabled' ) || {};
if ( featuresEnabled.newtopictool ) { if ( featuresEnabled.newtopictool ) {
// eslint-disable-next-line no-jquery/no-global-selector // eslint-disable-next-line no-jquery/no-global-selector
var $addSectionTab = $( '#ca-addsection' ); var $addSectionTab = $( '#ca-addsection' );
@ -203,8 +203,10 @@ ReplyLinksController.prototype.teardown = function () {
} }
this.$replyLinks.off( 'click keypress', this.onReplyLinkClickHandler ); this.$replyLinks.off( 'click keypress', this.onReplyLinkClickHandler );
if ( this.$addSectionLink ) { if ( featuresEnabled.newtopictool ) {
this.$addSectionLink.off( 'click keypress', this.onAddSectionLinkClickHandler ); if ( this.$addSectionLink ) {
this.$addSectionLink.off( 'click keypress', this.onAddSectionLinkClickHandler );
}
this.$body.off( 'click keypress', 'a:not( [data-mw-comment] )', this.onAnyLinkClickHandler ); this.$body.off( 'click keypress', 'a:not( [data-mw-comment] )', this.onAnyLinkClickHandler );
} }
}; };