-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[AssetMapper] es-module-shim script attributes conflicts with Turbo #59097
New issue
Have a question about 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
Comments
So we "just" need to "not pass" the attributes to the script, that's right ? |
In theory yes. |
@nicolas-grekas do you remember why you added all the attributes ? to handle CSP ? |
If CSP was the reason, adding |
I'm not fluent in CSP, I didn't think much of it. PR welcome. |
@nicolas-grekas |
I'd suggest we remove any CSP attribute per default on the polyfill loading script. Users can then chose to add custom attributes on this script (via config), or to hide it do things manually, etc etc |
I got it working by duplicating the inline script block which dynamically creates the shim script tag and removing both the I think removing these attributes on the resulting script tag would be the way to go:
On the other hand, the AssetMapper docs mention adding |
We encountered the same issue after upgrading from AssetMapper 7.1 to 7.2 in a project that uses symfony/ux-turbo. Form submissions reloaded page instead of replace. Adding asset_mapper:
importmap_script_attributes:
data-turbo-track: dynamic Side note: After upgrading AssetMapper, we also had to allow script-src: strict-dynamic in nelmio_security config. Without it, we saw following errors in browser console: |
Symfony version(s) affected
7.2.0
Description
Using CSP nonce on importmap generates different script body for the es-module-shim injection code on each request.
This conflicts with @hotwired/turbo element signature check - if the new and the old signature differs, the page is reloaded and not replaced/morphed.
#58121 introduced on-demand loading of the shim - all attributes that are added to the importmap script tag are also added as setAttribute calls in the injected script body.
How to reproduce
symfony/ux-turbo
)HeadSnapshot.trackedElementSignature
is different for the new page script body for es-module-shim is different, so the browser is navigated to the new page (normaly navigation)Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: