Skip to content

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

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

hirasso merged 5 commits into
swup:mainfrom
ovenum:feature/multiple-fragment-links

Conversation

@ovenum

@ovenum ovenum commented Nov 17, 2025 •

Copy link
Copy Markdown
Contributor

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

hirasso commented Nov 18, 2025

Copy link
Copy Markdown
Member

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

@ovenum

ovenum commented Nov 21, 2025

Copy link
Copy Markdown
Contributor Author

Looks like it’s ready for a review now.

@hirasso hirasso left a comment

Copy link
Copy Markdown
Member

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

hirasso commented Nov 25, 2025

Copy link
Copy Markdown
Member

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