diff --git a/src/Helper/HeadScript.php b/src/Helper/HeadScript.php index b1b8fb7a5..c9dd73a5f 100644 --- a/src/Helper/HeadScript.php +++ b/src/Helper/HeadScript.php @@ -34,6 +34,11 @@ class HeadScript extends Placeholder\Container\AbstractStandalone const FILE = 'FILE'; const SCRIPT = 'SCRIPT'; + /** + * @internal + */ + const DEFAULT_SCRIPT_TYPE = 'text/javascript'; + /** * Are arbitrary attributes allowed? * @@ -130,7 +135,7 @@ public function __invoke( $spec = null, $placement = 'APPEND', array $attrs = [], - $type = 'text/javascript' + $type = self::DEFAULT_SCRIPT_TYPE ) { if ((null !== $spec) && is_string($spec)) { $action = ucfirst(strtolower($mode)); @@ -171,7 +176,7 @@ public function __call($method, $args) $action = $matches['action']; $mode = strtolower($matches['mode']); - $type = 'text/javascript'; + $type = self::DEFAULT_SCRIPT_TYPE; $attrs = []; if ('offsetSet' == $action) { @@ -267,7 +272,7 @@ public function toString($indent = null) */ public function captureStart( $captureType = Placeholder\Container\AbstractContainer::APPEND, - $type = 'text/javascript', + $type = self::DEFAULT_SCRIPT_TYPE, $attrs = [] ) { if ($this->captureLock) { @@ -401,7 +406,10 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd) $addScriptEscape = ! (isset($item->attributes['noescape']) && filter_var($item->attributes['noescape'], FILTER_VALIDATE_BOOLEAN)); - if (empty($item->type) && $this->view && $this->view->plugin('doctype')->isHtml5()) { + if ((empty($item->type) || strtolower($item->type) === self::DEFAULT_SCRIPT_TYPE) + && $this->view + && $this->view->plugin('doctype')->isHtml5() + ) { $html = '