10000 [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

New issue

Have a question about C604 this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gundesli opened this issue Jan 18, 2025 · 0 comments · Fixed by #59549
Closed

[AssetMapper] ImportMap render w3c validator error #59547

gundesli opened this issue Jan 18, 2025 · 0 comments · Fixed by #59549

Comments

@gundesli
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0