Load styles in 'oojs-ui-widgets' again rather than a separate module
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 16 Aug 2018 21:46:21 +0000 (23:46 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 16 Aug 2018 21:48:02 +0000 (23:48 +0200)
OOUI's 'widgets' style module must be loaded after its 'core' style
module, because the styles need the rules to be in this order to work.

We can't enforce a dependency from 'oojs-ui-widgets.styles' on
'oojs-ui-core.styles', because it is a style-only module (it can't
have dependencies).

When both of these modules are loaded as style-only modules (using
addModuleStyles() in PHP), everything works fine, because they are
loaded in alphabetical order. But when they are loaded as dependencies
from JS code, the order is unspecified.

Move OOUI 'widgets' styles back into the 'oojs-ui-widgets' module
(partially reverting fc65ff17d9f132aa332c99f7da44b92f6a372826) to
avoid the problem.

When 'oojs-ui-widgets.styles' is loaded on a page that also includes
'oojs-ui-widgets' (e.g. Special:Preferences), unfortunately the styles
will be loaded twice. I don't see a way to avoid this problem.

Bug: T195544
Change-Id: Ia07189f96b423b218ecbc52acffdedca517d2b01

resources/Resources.php

index 710d54a..68404f4 100644 (file)
@@ -2872,9 +2872,9 @@ return [
        'oojs-ui-widgets' => [
                'class' => ResourceLoaderOOUIFileModule::class,
                'scripts' => 'resources/lib/oojs-ui/oojs-ui-widgets.js',
+               'themeStyles' => 'widgets',
                'dependencies' => [
                        'oojs-ui-core',
-                       'oojs-ui-widgets.styles',
                        'oojs-ui.styles.icons-interactions',
                        'oojs-ui.styles.icons-content',
                        'oojs-ui.styles.icons-editing-advanced',