From 3b057600d09b8013e14b0c5ea4696fb7eadc6022 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 18 Jul 2023 13:09:30 +0200 Subject: fix: Correctly add `module` content type to script tags when scripts with versions are used Signed-off-by: Ferdinand Thiessen --- tests/lib/TemplateFunctionsTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/lib') diff --git a/tests/lib/TemplateFunctionsTest.php b/tests/lib/TemplateFunctionsTest.php index b2b25ab654c..aa9ba32610d 100644 --- a/tests/lib/TemplateFunctionsTest.php +++ b/tests/lib/TemplateFunctionsTest.php @@ -86,6 +86,18 @@ class TemplateFunctionsTest extends \Test\TestCase { ]); } + public function testEmitScriptLoadingTagsWithVersion() { + // Test mjs js and inline content + $pattern = '/src="some\.mjs\?v=ab123cd"[^>]+type="module"[^>]*>.+\n'; // some.mjs with type = module + $pattern .= ']+src="other\.js\?v=12abc34"[^>]*>.+\n'; // other.js as plain javascript + $pattern .= '/'; // no flags + + $this->expectOutputRegex($pattern); + emit_script_loading_tags([ + 'jsfiles' => ['some.mjs?v=ab123cd', 'other.js?v=12abc34'], + ]); + } + // --------------------------------------------------------------------------- // Test relative_modified_date with dates only // --------------------------------------------------------------------------- -- cgit v1.2.3