diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index 47c76849c..c5bcbf0f8 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -487,7 +487,7 @@ public function addInlineJs($asset, $priority = null, $group = null, $attributes 'priority' => intval($priority ?: 10), 'order' => count($this->js), 'group' => $group ?: 'head', - 'type' => $attributes ?: '', + 'type' => $attributes ?: 'text/javascript', ]; // check for dynamic array and merge with defaults @@ -663,16 +663,11 @@ public function js($group = 'head', $attributes = []) // Render Inline JS foreach ($this->inline_js as $inline) { - if ($group && $inline['group'] == $group) { - $inline_js .= $inline['asset'] . "\n"; - } + if ($group && $inline['group'] === $group) { + $attributeString = " type=\"" . $inline['type'] . "\""; + $output .= "\n\n" . $inline['asset'] . "\n\n"; + } } - - if ($inline_js) { - $attribute_string = isset($inline) && $inline['type'] ? " type=\"" . $inline['type'] . "\"" : ''; - $output .= "\n\n" . $inline_js . "\n\n"; - } - return $output; }