mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
script_tag: changelog, doc + test with default arg
This commit is contained in:
parent
a8d5b894c9
commit
4fd7ac5830
@ -189,8 +189,8 @@ if (! function_exists('script_tag')) {
|
||||
*
|
||||
* Generates link to a JS file
|
||||
*
|
||||
* @param mixed $src Script source or an array
|
||||
* @param bool $indexPage Should indexPage be added to the JS path
|
||||
* @param array|string $src Script source or an array of attributes
|
||||
* @param bool $indexPage Should indexPage be added to the JS path
|
||||
*/
|
||||
function script_tag($src = '', bool $indexPage = false): string
|
||||
{
|
||||
|
@ -269,6 +269,16 @@ final class HTMLHelperTest extends CIUnitTestCase
|
||||
$this->assertSame($expected, script_tag($target));
|
||||
}
|
||||
|
||||
/**
|
||||
* This test has probably no real-world value but may help detecting
|
||||
* a change in the default behaviour.
|
||||
*/
|
||||
public function testScriptTagWithoutAnyArg()
|
||||
{
|
||||
$expected = '<script src="http://example.com/" type="text/javascript"></script>';
|
||||
$this->assertSame($expected, script_tag());
|
||||
}
|
||||
|
||||
public function testLinkTag()
|
||||
{
|
||||
$target = 'css/mystyles.css';
|
||||
|
@ -38,6 +38,7 @@ Enhancements
|
||||
- The log format has also changed. If users are depending on the log format in their apps, the new log format is "<1-based count> <cleaned filepath>(<line>): <class><function><args>"
|
||||
- Added support for webp files to **app/Config/Mimes.php**.
|
||||
- Added 4th parameter ``$includeDir`` to ``get_filenames()``. See :php:func:`get_filenames`.
|
||||
- HTML helper ``script_tag()`` now uses ``null`` values to write boolean attributes in minimized form: ``<script src="..." defer />``. See the sample code for :php:func:`script_tag`.
|
||||
|
||||
Changes
|
||||
*******
|
||||
|
@ -104,8 +104,8 @@ The following functions are available:
|
||||
|
||||
.. php:function:: script_tag([$src = ''[, $indexPage = false]])
|
||||
|
||||
:param mixed $src: The source name of a JavaScript file
|
||||
:param bool $indexPage: Whether to treat ``$src`` as a routed URI string
|
||||
:param array|string $src: The source name or URL of a JavaScript file, or an associative array specifying the attributes
|
||||
:param bool $indexPage: Whether to treat ``$src`` as a routed URI string
|
||||
:returns: HTML script tag
|
||||
:rtype: string
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user