swup / fragment-plugin

A swup plugin for dynamically replacing containers based on rules 🧩
https://swup-fragment-plugin.netlify.app
MIT License
15 stars 1 forks source link

feat: optimize get fragment visit #79

Closed hirasso closed 3 months ago

hirasso commented 3 months ago

Description

I just stumbled upon a case where the sole fragment that was being targeted for the current visit already had the same fragment url as visit.to.url, causing a normal (non-fragment) visit that broke as of course the containers were missing (hard to explain 😅). ~Allowing visits that don't replace anything was exactly what I needed in this case~.

Actually, the comment I posted below lead me to the real solution: Treat a visit as a reload, if all fragment elements already match that visit's visit.to.url. In other words: Don't skip fragments as described in https://swup.js.org/plugins/fragment-plugin/#how-fragment-containers-are-found, bullet 3, if otherwise no fragments would be replaced at all.

Drive-By

Checks

Additional information

github-actions[bot] commented 3 months ago

Playwright test results

passed  12 passed

Details

stats  12 tests across 1 suite
duration  
commit  6b6d10d

hirasso commented 3 months ago

An alternative could be to check if all containers for the current visit already match the visit.to.url, and if so, replace them anyways. @daun Maybe this is something we should discuss in a call.

hirasso commented 3 months ago

Closing this as I'd like to go through all this in an issue first.