?
avatar yild
yild
7 Jan 2021

Steps to reproduce the issue

  1. Set $this->setHtml5(true); in template index.php.
  2. Use code:
 $doc = JFactory::getDocument();

 $doc->addScriptDeclaration();
 $doc->addStyleDeclaration();

ie. used in plugins.

  1. Validate rendered page at ie. validator.w3.org.

Expected result

No warnings after page validation when using HTML5.

Actual result

Validation warnings with messages like:

The type attribute is unnecessary for JavaScript resources.
The type attribute is unnecessary for Style resources.

ATM functions addScriptDeclaration() and addStyleDeclaration() doesnt use $doc->isHtml5(); value to generate correct html code.

System information (as much as possible)

Tested on Joomla! 3.9.22

avatar yild yild - open - 7 Jan 2021
avatar joomla-cms-bot joomla-cms-bot - change - 7 Jan 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 7 Jan 2021
avatar C-Lodder
C-Lodder - comment - 7 Jan 2021

The type attribute isn't required for HTML5. If it's not present, the browser will treat it as a classic JS script.
You can be course set it to type=module or something else, depending on the type of script you're writing.

Same goes for type=text/css on <style> elements. It's simply not required.

I'd refrain from using validator.w3.org as it's seriously outdated.

avatar brianteeman
brianteeman - comment - 7 Jan 2021

Please retest and change the doc type to html5
image

avatar sandramay0905
sandramay0905 - comment - 13 Apr 2021

@yild what is your experience using above comments?

avatar brianteeman
brianteeman - comment - 25 Apr 2021

This should be closed as the question as asked and answred

avatar Fedik Fedik - change - 25 Apr 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-04-25 13:11:13
Closed_By Fedik
avatar Fedik Fedik - close - 25 Apr 2021
avatar Fedik
Fedik - comment - 25 Apr 2021

answered

Add a Comment

Login with GitHub to post a comment