mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-09-24 10:58:20 +00:00
d7aded339c
The hook 'wikipage.content' fires whenever new "page content" is added dynamically (e.g. after a VisualEditor edit). It's used by the code for sortable tables, collapsible content, etc., to ensure they behave correctly after the page content is changed without reloading the page. We use this hook to add our "Reply" links. However, VisualEditor (and NWE) also fires this hook for the contents of the edit notices box (to support collapsible boxes there: T179315). Our code was crashing because it could not find talk page content inside of that, and this crashed VisualEditor as well. Use .each() to handle any number of results (0, 1 or more), instead of assuming there is always 1. Bug: T241396 Change-Id: I877b1ae06bf1d7cd585ec6f9c1fb596cc3b86e7e
21 lines
529 B
JavaScript
21 lines
529 B
JavaScript
var controller = require( 'ext.discussionTools.controller' );
|
|
|
|
/**
|
|
* @class mw.dt
|
|
* @singleton
|
|
*/
|
|
mw.dt = {};
|
|
|
|
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 ) );
|
|
} );
|
|
}
|
|
} );
|
|
}
|