Skip to content

Support multiple fragment selectors in data-swup-link-to-fragment attribute#92

Merged
hirasso merged 5 commits intoswup:mainfrom
ovenum:feature/multiple-fragment-links
Nov 25, 2025
Merged

Support multiple fragment selectors in data-swup-link-to-fragment attribute#92
hirasso merged 5 commits intoswup:mainfrom
ovenum:feature/multiple-fragment-links

Conversation

@ovenum
Copy link
Copy Markdown
Contributor

@ovenum ovenum commented Nov 17, 2025

Description
Adds support for multiple comma-separated fragment selectors in the data-swup-link-to-fragment attribute. Previously, only a single selector was supported. Now users can specify multiple selectors where the first matching element will be used for updating the fragment link.

This is usefull for modals shown on-top of content which renders another swup fragment (filtered or paginated lists for example).

<!-- Before -->
<dialog data-swup-link-to-fragment="#filtered-list">[…]</dialog>

<!-- Possible with this PR -->
<dialog data-swup-link-to-fragment="#filtered-list, #main">[…]</dialog>

TODO

  • Add better debug messages reflecting which fragment was resolved for data-swup-link-to-fragment.

Checks

  • The PR is submitted to the main branch
  • The code was linted before pushing (npm run lint)
  • All tests are passing (npm run test)
  • New or updated tests are included
  • The documentation was updated as required

Additional information

@hirasso
Copy link
Copy Markdown
Member

hirasso commented Nov 18, 2025

This looks great! Happy to merge when all boxes are ticked :)

@ovenum
Copy link
Copy Markdown
Contributor Author

ovenum commented Nov 21, 2025

Looks like it’s ready for a review now.

Copy link
Copy Markdown
Member

@hirasso hirasso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thank you

@hirasso hirasso merged commit 60d13a5 into swup:main Nov 25, 2025
2 checks passed
@hirasso
Copy link
Copy Markdown
Member

hirasso commented Nov 25, 2025

Released in 1.2.0

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants