Skip to content
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

[Turbo] data-turbo-track attribute for CSS is missing #2137

Open
seb-jean opened this issue Sep 8, 2024 · 6 comments
Open

[Turbo] data-turbo-track attribute for CSS is missing #2137

seb-jean opened this issue Sep 8, 2024 · 6 comments
Labels
Status: Waiting Feedback Needs feedback from the author Turbo

Comments

@seb-jean
Copy link
Contributor

seb-jean commented Sep 8, 2024

Hi :),

I see that the JS links have the data-turbo-track attribute but not the CSS ones:
https://github.com/symfony/ux/blob/2.x/src/Turbo/src/DependencyInjection/TurboExtension.php#L102

https://turbo.hotwired.dev/reference/attributes

@carsonbot carsonbot added the Turbo label Sep 8, 2024
@seb-jean seb-jean changed the title [Turbo] data-turbo-track attribute for CSS [Turbo] data-turbo-track attribute for CSS is missing Sep 8, 2024
@smnandre
Copy link
Member

smnandre commented Sep 8, 2024

I see that the JS links have the data-turbo-track attribute but not the CSS ones:

Not "the JS links", only the importmap script, if AssetMapper is installed :)

Are you suggesting a new feature ? Or is there something not working as you'd expect ?

@smnandre smnandre added the Status: Waiting Feedback Needs feedback from the author label Sep 8, 2024
@seb-jean
Copy link
Contributor Author

seb-jean commented Sep 8, 2024

For https://ux.symfony.com/ there is the following source code:

Capture d'écran 2024-09-08 224749

Shouldn't that be it?

[...]
<link rel="stylesheet" href="/assets/styles/app-e6e5573999adb63729abd6652c7ebcd5.css" data-turbo-track="reload">
<link rel="stylesheet" href="/assets/vendor/tippy.js/dist/tippy-2cffb277c396057474574f721014a03f.css" data-turbo-track="reload">
<link rel="stylesheet" href="/assets/vendor/tippy.js/themes/translucent-02f3023fa2e1a35311c7e80893e98a69.css" data-turbo-track="reload">
<script type="importmap" data-turbo-track="reload">
[...]

@smnandre
Copy link
Member

smnandre commented Sep 8, 2024

Can you explain why?

I do not agree nor disagree here, it's a genuine question :)

Is it always the case ? Or something developper should set manually ?

It seems logical to me on the importmap, but i feel (i may be wrong) that stylesheet rule would be really hard to generalize

Could you illustrate on the website what would be the effect / in which scénario ? :)

@smnandre
Copy link
Member

These are genuine questions :)

@seb-jean
Copy link
Contributor Author

I don't have an example to give you :/. I saw it used on https://app.hey.com/.

@smnandre
Copy link
Member

Well, i don't think we can do it with AssetMapper / ImportMap for now.... at least not with the importmap() function.

https://github.com/symfony/symfony/blob/44395abfcb2c859b26e0c6880c74dadd94da1038/src/Symfony/Component/AssetMapper/ImportMap/ImportMapRenderer.php#L140-L144

        foreach ($modulePreloads as $url) {
            $url = $this->escapeAttributeValue($url);

            $output .= "\n<link rel=\"modulepreload\" href=\"$url\">";
        }

But this could be a good PR for AssetMapper :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Waiting Feedback Needs feedback from the author Turbo
Projects
None yet
Development

No branches or pull requests

3 participants