Fix re-initialization after page is updated

I did this wrong in a6147ffac8, the
'dt-init-done' class was never cleared. Put it on another element.

Bug: T241861
Change-Id: I136bd9c12bcc80cff01f5d26a8a53524f0c533c6
This commit is contained in:
Bartosz Dziewoński 2020-01-04 18:48:52 +01:00
parent d7aded339c
commit 25eb55000f
2 changed files with 9 additions and 7 deletions

View file

@ -10,11 +10,13 @@ if ( new mw.Uri().query.dtdebug ) {
mw.loader.load( 'ext.discussionTools.debug' );
} else {
mw.hook( 'wikipage.content' ).add( function ( $container ) {
// Don't re-run if we already handled this element
if ( $container.closest( '.dt-init-done' ).length === 0 ) {
$container.find( '#mw-content-text' ).addBack( '#mw-content-text' ).each( function () {
controller.init( $( this ) );
} );
}
$container.find( '.mw-parser-output' ).each( function () {
var $node = $( this );
// Don't re-run if we already handled this element
// eslint-disable-next-line no-jquery/no-class-state
if ( !$node.hasClass( 'dt-init-done' ) ) {
controller.init( $node );
}
} );
} );
}

View file

@ -243,7 +243,7 @@ ReplyWidget.prototype.onReplyClick = function () {
// (see ve.init.mw.DesktopArticleTarget.prototype.replacePageContent)
// Re-initialize
controller.init( $container, {
controller.init( $container.find( '.mw-parser-output' ), {
repliedTo: repliedTo
} );
mw.hook( 'wikipage.content' ).fire( $container );