diff options
author | Christian Schneider | 2025-10-14 16:48:37 +0200 |
---|---|---|
committer | Christian Schneider | 2025-10-14 16:50:24 +0200 |
commit | 26185bb4f1824d3cc96824d94f35cb241d344028 (patch) | |
tree | 96a28339fc90858e080853317625f8dd31b25d8c /it_html.class | |
parent | aef9268f09a332d56d6f0a7136eb20084a6bd32a (diff) | |
download | itools-26185bb4f1824d3cc96824d94f35cb241d344028.tar.gz itools-26185bb4f1824d3cc96824d94f35cb241d344028.tar.bz2 itools-26185bb4f1824d3cc96824d94f35cb241d344028.zip |
Simplify js() function and fix boolean attributes like 'async' => true, add tests for it
Diffstat (limited to 'it_html.class')
-rw-r--r-- | it_html.class | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/it_html.class b/it_html.class index 9bb8e7a..bab85da 100644 --- a/it_html.class +++ b/it_html.class @@ -546,18 +546,16 @@ static function U(...$args) */ function js($args) { - $args = it::map(fn($v) => it::replace(['<!--' => '\\x3C!--', '<script' => '\\x3Cscript', '</script' => '\\x3C/script'], $v), $args); + list($base, $params) = it_parse_args($args); + $base= it::replace(['<!--' => '\\x3C!--', '<script' => '\\x3Cscript', '</script' => '\\x3C/script'], $base); - if (($this->p['htmltype'][0] == 'x') && $args[0] && ((array)$args[0] === array_values((array)$args[0]))) - { - array_unshift($args, "<!--//--><![CDATA[//><!--\n"); - $args[] = "\n//--><!]]>"; - } + if (($this->p['htmltype'][0] == 'x') && strlen($base)) + $base = "<!--//--><![CDATA[//><!--\n$base\n//--><!]]>"; if ($this->p['htmltype'] != "html5") - array_unshift($args, array('type' => 'text/javascript')); + $params['type'] = 'text/javascript'; - return $this->_tag('script', $args); + return $this->_tag('script', [$base, $params]); } |