'general' => [],
],
// Deprecations for style-only modules
- 'styledeprecations' => [],
+ 'styleDeprecations' => [],
];
foreach ( $this->modules as $name ) {
}
$deprecation = $module->getDeprecationInformation();
if ( $deprecation ) {
- $data['styledeprecations'][] = $deprecation;
+ $data['styleDeprecations'][] = $deprecation;
}
}
);
}
- // Deprecations for only=styles modules
- if ( $data['styledeprecations'] ) {
- $chunks[] = ResourceLoader::makeInlineScript(
- implode( '', $data['styledeprecations'] ),
- $nonce
- );
- }
-
// External stylesheets (only=styles)
if ( $data['styles'] ) {
$chunks[] = $this->getLoad(
* @return string|WrappedStringList HTML
*/
public function getBodyHtml() {
- return '';
+ $data = $this->getData();
+ $chunks = [];
+
+ // Deprecations for only=styles modules
+ if ( $data['styleDeprecations'] ) {
+ $chunks[] = ResourceLoader::makeInlineScript(
+ implode( '', $data['styleDeprecations'] ),
+ $this->options['nonce']
+ );
+ }
+
+ return WrappedStringList::join( "\n", $chunks );
}
private function getContext( $group, $type ) {
'test.user',
],
],
- 'styledeprecations' => [
+ 'styleDeprecations' => [
Xml::encodeJsCall(
'mw.log.warn',
[ 'This page is using the deprecated ResourceLoader module "test.styles.deprecated".
. 'mw.loader.implement("test.private@{blankVer}",function($,jQuery,require,module){},{"css":[]});'
. 'mw.loader.load(["test"]);'
. 'mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.scripts\u0026only=scripts\u0026skin=fallback");'
- . 'mw.log.warn("This page is using the deprecated ResourceLoader module \"test.styles.deprecated\".\nDeprecation message.");'
. '});</script>' . "\n"
. '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.deprecated%2Cpure&only=styles&skin=fallback"/>' . "\n"
. '<style>.private{}</style>' . "\n"
$context = self::makeContext();
$context->getResourceLoader()->register( self::makeSampleModules() );
- $client = new ResourceLoaderClientHtml( $context );
+ $client = new ResourceLoaderClientHtml( $context, [ 'nonce' => false ] );
$client->setConfig( [ 'key' => 'value' ] );
$client->setModules( [
'test',
'test.private.bottom',
] );
+ $client->setModuleStyles( [
+ 'test.styles.deprecated',
+ ] );
$client->setModuleScripts( [
'test.scripts',
] );
-
- $expected = '';
- $expected = self::expandVariables( $expected );
+ // phpcs:disable Generic.Files.LineLength
+ $expected = '<script>(window.RLQ=window.RLQ||[]).push(function(){'
+ . 'mw.log.warn("This page is using the deprecated ResourceLoader module \"test.styles.deprecated\".\nDeprecation message.");'
+ . '});</script>';
+ // phpcs:enable
$this->assertEquals( $expected, $client->getBodyHtml() );
}