Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## Release Notes

### BootstrapComponents 6.1.1

Released on TBD

Fixes:
* stop logging `Unexpected general module ... in styles queue.` on pages using a modal, carousel, tooltip or popover

### BootstrapComponents 6.1.0

Released on 21-July-2026
Expand Down
23 changes: 20 additions & 3 deletions src/HooksHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use MediaWiki\Hook\SetupAfterCacheHook;
use MediaWiki\MediaWikiServices;
use MediaWiki\Parser\Parser;
use MediaWiki\Parser\ParserOutput;
use MediaWiki\ResourceLoader\Module;
use SMW\Utils\File;
use StripState;

Expand Down Expand Up @@ -245,14 +247,29 @@ public function onParserAfterParse( $parser, &$text, $stripState ): bool {
if ( !$this->getComponentLibrary()->isRegistered( $activeComponent ) ) {
continue;
}
foreach ( $this->getComponentLibrary()->getModulesFor( $activeComponent, 'vector' ) as $module ) {
$parser->getOutput()->addModuleStyles( [ $module ] );
$parser->getOutput()->addModules( [ $module ] );
foreach ( $this->getComponentLibrary()->getModulesFor( $activeComponent, 'vector' ) as $moduleName ) {
$this->addModuleToMatchingQueue( $parser->getOutput(), $moduleName );
}
}
return true;
}

/**
* ResourceLoader discards anything but a styles-only module from the styles queue, so a module
* that also carries scripts, dependencies, messages or templates has to go to the general
* queue, which delivers its styles too.
*/
private function addModuleToMatchingQueue( ParserOutput $parserOutput, string $moduleName ): void {
$module = MediaWikiServices::getInstance()->getResourceLoader()->getModule( $moduleName );

if ( $module !== null && $module->getType() === Module::LOAD_STYLES ) {
$parserOutput->addModuleStyles( [ $moduleName ] );
return;
}

$parserOutput->addModules( [ $moduleName ] );
}

/**
* Hook: ParserFirstCallInit
*
Expand Down
32 changes: 32 additions & 0 deletions tests/phpunit/Unit/HooksHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,38 @@ public function testOnParserAfterParseAddsOnlyTheStylesFix() {
$this->assertNotContains( 'ext.bootstrap.scripts', $parserOutput->getModules() );
}

public function testOnParserAfterParseSplitsComponentModulesByType() {
$parserOutput = $this->parserOutputWithActiveComponent( 'modal' );

$this->assertSame(
[
'ext.bootstrapComponents.bootstrap.fix',
'ext.bootstrapComponents.button.fix',
'ext.bootstrapComponents.modal.vector-fix',
],
$parserOutput->getModuleStyles()
);
$this->assertSame( [ 'ext.bootstrapComponents.modal.fix' ], $parserOutput->getModules() );
}

private function parserOutputWithActiveComponent( string $componentName ): ParserOutput {
$bootstrapComponentsService = new BootstrapComponentsService( new TestConfig() );
$bootstrapComponentsService->registerComponentAsActive( $componentName );
$parserOutput = new ParserOutput();
$parser = $this->createMock( Parser::class );
$parser->method( 'getOutput' )->willReturn( $parserOutput );
$text = '';

$hooksHandler = new HooksHandler(
$bootstrapComponentsService,
new ComponentLibrary(),
$this->createMock( NestingController::class ),
);
$hooksHandler->onParserAfterParse( $parser, $text, null );

return $parserOutput;
}

public function testOnBeforePageDisplayLoadsExtensionBootstrapOnNonProviderContentPage() {
$out = $this->createMock( OutputPage::class );
$out->method( 'getModuleStyles' )->willReturn( [ 'ext.bootstrapComponents.bootstrap.fix' ] );
Expand Down