Skip to content

Script is not processed when it is in multiple slots where one uses Fragment and the other slot is not included #13847

@tamashalasi

Description

@tamashalasi

Astro Info

Astro                    v5.8.0
Node                     v22.12.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/sitemap
                         @playform/compress
                         astro-broken-links-checker

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

As that can be seen in the title, this is a very specific issue: Scripts are not processed when they are in multiple slots where at least one slot uses Fragment and the other slot(s) are not included.

See the reproduction in StackBlitz. The script (in Test2) is not processed when it is in included in multiple slots where one uses Fragment and the other slot is not included in the final output of the page. If you open the example you can see that Test2 is not executed as otherwise the "script is working!" would be shown on the page. If you change the Fragment slot="prod" to div slot="prod", the issue disappears. It seems like this issue only appears if at least one of slots is using Fragment. This also applies if both slots are using fragment and no default slot is used.

What's the expected result?

The script should be bundled when it is included in the page, so in the example, "hello" should be shown in the console.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-yah7uvqt?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P4: importantViolate documented behavior or significantly impacts performance (priority)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions