8000 [AssetMapper] ImportMap render w3c validator error · Issue #59547 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[AssetMapper] ImportMap render w3c validator error #59547
Closed
@gundesli

Description

@gundesli

Symfony version(s) affected

7.2.2

Description

Hi,

I've run a test with w3c validator and I get an error in the script tags generated by importMap :

Error: Element script must not have attribute async unless attribute src is also specified or unless attribute type is specified with value module.
From line 48, column 10; to line 48, column 23
</script><script async>↩if (!

The class concerned is ImportMapRender.php, line 128 :

$output .= <<<HTML
                <script async$scriptAttributes>
                if (!HTMLScriptElement.supports || !HTMLScriptElement.supports('importmap')) (function () {
                    const script = document.createElement('script');
                    script.src = '{$this->escapeAttributeValue($polyfillPath, \ENT_NOQUOTES)}';
                    script.setAttribute('async', 'async');
                    {$this->createAttributesString($polyfillAttributes, "script.setAttribute('%s', '%s');", "\n    ", \ENT_NOQUOTES)}
                    document.head.appendChild(script);
                })();
                </script>
                HTML;

async in the script tag seems to be a problem.

How to reproduce

Use the import map in your symfony project.

In base.html.twig file, add this lines :

       {% block javascripts %}
            {% block importmap %}
                {{ importmap('app') }}
            {% endblock %}
        {% endblock %}

Generate the html page and pas code in W3C validator : https://validator.w3.org/nu/#textarea

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0