// Special module that always exists
$this->register( 'startup', [ 'class' => ResourceLoaderStartUpModule::class ] );
- // Register extension modules
- $this->register( $config->get( 'ResourceModules' ) );
-
- // Avoid PHP 7.1 warning from passing $this by reference
- $rl = $this;
- Hooks::run( 'ResourceLoaderRegisterModules', [ &$rl ] );
-
- if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
- $this->registerTestModules();
- }
-
$this->setMessageBlobStore( new MessageBlobStore( $this, $this->logger ) );
}
}
}
+ /**
+ * @internal For use by ServiceWiring only
+ */
public function registerTestModules() {
global $IP;
if ( !$context->getDebug() ) {
$strContent = self::filter( $filter, $strContent );
+ } else {
+ // In debug mode, separate each response by a new line.
+ // For example, between 'mw.loader.implement();' statements.
+ $strContent = $this->ensureNewline( $strContent );
}
if ( $context->getOnly() === 'scripts' ) {
*/
public static function makeLoaderConditionalScript( $script ) {
// Adds a function to lazy-created RLQ
- return '(window.RLQ=window.RLQ||[]).push(function(){' .
+ return '(RLQ=window.RLQ||[]).push(function(){' .
trim( $script ) . '});';
}
*/
public static function makeInlineCodeWithModule( $modules, $script ) {
// Adds an array to lazy-created RLQ
- return '(window.RLQ=window.RLQ||[]).push(['
+ return '(RLQ=window.RLQ||[]).push(['
. self::encodeJsonForScript( $modules ) . ','
. 'function(){' . trim( $script ) . '}'
. ']);';
return new WrappedString(
Html::inlineScript( $js, $nonce ),
- "<script$escNonce>(window.RLQ=window.RLQ||[]).push(function(){",
+ "<script$escNonce>(RLQ=window.RLQ||[]).push(function(){",
'});</script>'
);
}