Merge "Always load init CSS when tools are available for a title"

This commit is contained in:
jenkins-bot 2021-03-06 18:51:46 +00:00 committed by Gerrit Code Review
commit 42b70dff1c
2 changed files with 11 additions and 3 deletions

View file

@ -26,7 +26,11 @@
},
"ResourceModules": {
"ext.discussionTools.init.styles": {
"styles": "dt.init.less"
"styles": "dt.init.less",
"targets": [
"desktop",
"mobile"
]
},
"ext.discussionTools.init": {
"packageFiles": [

View file

@ -32,11 +32,15 @@ class PageHooks implements
*/
public function onBeforePageDisplay( $output, $skin ) : void {
$user = $output->getUser();
// Load modules if any DT feature is enabled for this user
if ( HookUtils::isFeatureEnabledForOutput( $output ) ) {
// Load style modules if the tools can be available for the title
// as this means the DOM may have been modified in the parser cache.
if ( HookUtils::isAvailableForTitle( $output->getTitle() ) ) {
$output->addModuleStyles( [
'ext.discussionTools.init.styles'
] );
}
// Load modules if any DT feature is enabled for this user
if ( HookUtils::isFeatureEnabledForOutput( $output ) ) {
$output->addModules( [
'ext.discussionTools.init'
] );