'user.options',
'user.tokens',
] );
- $rlClient = new ResourceLoaderClientHtml( $context );
+ $rlClient = new ResourceLoaderClientHtml( $context, $this->getTarget() );
$rlClient->setConfig( $this->getJSVars() );
$rlClient->setModules( $this->getModules( /*filter*/ true ) );
$rlClient->setModuleStyles( $this->getModuleStyles( /*filter*/ true ) );
* @return string|WrappedStringList HTML
*/
public function makeResourceLoaderLink( $modules, $only, array $extraQuery = [] ) {
+ // Apply 'target' and 'origin' filters
+ $modules = $this->filterModules( (array)$modules, null, $only );
+
return ResourceLoaderClientHtml::makeLoad(
$this->getRlClientContext(),
- (array)$modules,
+ $modules,
$only,
$extraQuery
);
/** @var ResourceLoader */
private $resourceLoader;
+ /** @var string|null */
+ private $target;
+
/** @var array */
private $config = [];
/**
* @param ResourceLoaderContext $context
+ * @param aray $target [optional] Custom 'target' parameter for the startup module
*/
- public function __construct( ResourceLoaderContext $context ) {
+ public function __construct( ResourceLoaderContext $context, $target = null ) {
$this->context = $context;
$this->resourceLoader = $context->getResourceLoader();
+ $this->target = $target;
}
/**
}
// Async scripts. Once the startup is loaded, inline RLQ scripts will run.
- $chunks[] = $this->getLoad( 'startup', ResourceLoaderModule::TYPE_SCRIPTS );
+ // Pass-through a custom target from OutputPage (T143066).
+ $startupQuery = $this->target ? [ 'target' => $this->target ] : [];
+ $chunks[] = $this->getLoad(
+ 'startup',
+ ResourceLoaderModule::TYPE_SCRIPTS,
+ $startupQuery
+ );
return WrappedStringList::join( "\n", $chunks );
}
return self::makeContext( $this->context, $group, $type );
}
- private function getLoad( $modules, $only ) {
- return self::makeLoad( $this->context, (array)$modules, $only );
+ private function getLoad( $modules, $only, array $extraQuery = [] ) {
+ return self::makeLoad( $this->context, (array)$modules, $only, $extraQuery );
}
private static function makeContext( ResourceLoaderContext $mainContext, $group, $type,