Skip to content
Snippets Groups Projects
Commit 36f1473f authored by Geoff Appleby's avatar Geoff Appleby
Browse files

Issue #3167803 by bburg, gapple: Allow attributes on elements

parent 1149818f
Branches
Tags
No related merge requests found
......@@ -25,6 +25,9 @@ $render['element'] = [
[
'data' => '.highlight { background-color: yellow; }',
'group' => CSS_THEME,
'attributes' => [
'media' => 'all',
]
],
],
],
......
......@@ -76,6 +76,7 @@ class CssCollectionRendererDecorator implements AssetCollectionRendererInterface
'#type' => 'html_tag',
'#tag' => 'style',
'#value' => '',
'#attributes' => [],
];
// Loop through all JS assets.
......@@ -87,6 +88,10 @@ class CssCollectionRendererDecorator implements AssetCollectionRendererInterface
$element = $element_defaults;
$element['#value'] = AttachInlineMarkup::create($css_asset['data']);
if (!empty($css_asset['attributes'])) {
$element['#attributes'] += $css_asset['attributes'];
}
if ($this->moduleHandler->moduleExists('csp')) {
$allowMethod = $this->config->get('attachinline.settings')->get('csp-allow-method') ?? 'hash';
if ($allowMethod == 'nonce') {
......
......@@ -76,6 +76,7 @@ class JsCollectionRendererDecorator implements AssetCollectionRendererInterface
'#type' => 'html_tag',
'#tag' => 'script',
'#value' => '',
'#attributes' => [],
];
// Loop through all JS assets.
......@@ -87,6 +88,10 @@ class JsCollectionRendererDecorator implements AssetCollectionRendererInterface
$element = $element_defaults;
$element['#value'] = AttachInlineMarkup::create($js_asset['data']);
if (!empty($js_asset['attributes'])) {
$element['#attributes'] += $js_asset['attributes'];
}
if ($this->moduleHandler->moduleExists('csp')) {
$allowMethod = $this->config->get('attachinline.settings')->get('csp-allow-method') ?? 'hash';
if ($allowMethod == 'nonce') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment