'styles' => [],
'general' => [],
],
-
+ // Deprecations for style-only modules
+ 'styledeprecations' => [],
];
foreach ( $this->modules as $name ) {
$data['styles'][] = $name;
}
}
+ $deprecation = $module->getDeprecationInformation();
+ if ( $deprecation ) {
+ $data['styledeprecations'][] = $deprecation;
+ }
}
foreach ( $this->moduleScripts as $name ) {
);
}
- // External stylesheets
+ // 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(
$data['styles'],
'shouldEmbed' => true,
'styles' => '.shouldembed{}',
],
+ 'test.styles.deprecated' => [
+ 'type' => ResourceLoaderModule::LOAD_STYLES,
+ 'deprecated' => 'Deprecation message.',
+ ],
'test.scripts' => [],
'test.scripts.user' => [ 'group' => 'user' ],
'test.styles.private',
'test.styles.pure',
'test.styles.shouldembed',
+ 'test.styles.deprecated',
'test.unregistered.styles',
] );
$client->setModuleScripts( [
'test.styles.user.empty' => 'ready',
'test.styles.private' => 'ready',
'test.styles.shouldembed' => 'ready',
+ 'test.styles.deprecated' => 'ready',
'test.scripts' => 'loading',
'test.scripts.user' => 'loading',
'test.scripts.user.empty' => 'ready',
],
'styles' => [
'test.styles.pure',
+ 'test.styles.deprecated',
],
'scripts' => [
'test.scripts',
'test.user',
],
],
+ 'styledeprecations' => [
+ Xml::encodeJsCall(
+ 'mw.log.warn',
+ [ 'This page is using the deprecated ResourceLoader module "test.styles.deprecated".
+Deprecation message.' ]
+ )
+ ],
];
$access = TestingAccessWrapper::newFromObject( $client );
$client->setModuleStyles( [
'test.styles.pure',
'test.styles.private',
+ 'test.styles.deprecated',
] );
$client->setModuleScripts( [
'test.scripts',
$expected = '<script>document.documentElement.className = document.documentElement.className.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );</script>' . "\n"
. '<script>(window.RLQ=window.RLQ||[]).push(function(){'
. 'mw.config.set({"key":"value"});'
- . 'mw.loader.state({"test.exempt":"ready","test.private":"loading","test.styles.pure":"ready","test.styles.private":"ready","test.scripts":"loading"});'
+ . 'mw.loader.state({"test.exempt":"ready","test.private":"loading","test.styles.pure":"ready","test.styles.private":"ready","test.styles.deprecated":"ready","test.scripts":"loading"});'
. '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.pure&only=styles&skin=fallback"/>' . "\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"
. '<script async="" src="/w/load.php?debug=false&lang=nl&modules=startup&only=scripts&skin=fallback"></script>';
// phpcs:enable