-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Progressively enhanced navigation #48899
Progressively enhanced navigation #48899
Conversation
9411d16
to
ef4d392
Compare
41d8a58
to
b06b0a0
Compare
@@ -9,7 +9,7 @@ export function synchronizeAttributes(destination: Element, source: Element) { | |||
|
|||
// Optimize for the common case where all attributes are unchanged and are even still in the same order | |||
const destAttrsLength = destAttrs.length; | |||
if (destAttrsLength === destAttrs.length) { | |||
if (destAttrsLength === sourceAttrs.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a bug here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I could backport the fix and add another test case to the earlier PR, but it didn't seem worthwhile when both of those things are going in on the same day with this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's ok, as long as we have a test to cover it, that's good enough
synchronizeDomContent(document, parsedHtml); | ||
} else if ((response.status < 200 || response.status >= 300) && !initialContent) { | ||
// For any non-success response that has no content at all, make up our own error UI | ||
document.documentElement.innerHTML = `Error: ${response.status} ${response.statusText}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you'll actually see the redirects here.
AFAIK, fetch automatically follows the redirects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, great point. I'll add some further test cases for redirections and make sure we're handling it sensibly (updating the history stack too).
…plete implementation of #48763 but will be OK for preview 6.
96553e9
to
75323b1
Compare
Implements #48761
This extends
blazor.web.js
so that when clicking to navigate between pages or using back/forwards, we attempt to perform the navigation via afetch
request and updating the DOM in place.The main complexities are:
Intentional limitation for .NET 8
We are not going to support having both "progressively-enhanced nav" and "interactive router" at the same time. As soon as you add any interactive
<Router/>
, we will automatically disable enhanced nav.This is because there are two important routing scenarios we need to support:
<Router/>
). In this mode, the router takes over all navigation operations and expects to find some content for every URL you visit (and if not, falls back on a full-page load which may renderNotFoundContent
). It doesn't make sense to navigate to content through enhanced nav because if the router doesn't know about a given URL, it's going to fall back on full-page load anyway, and by default that will then showNotFoundContent
.<Router/>
). In this mode there's no<Router/>
so we do enhanced nav.... and in neither case does it make sense to have enhanced nav enabled while there's an interactive
<Router/>
.In theory you could use both SPA and MPA routing styles in different parts of the same site, but it would be hard to set up.
<Router/>
is added via enhanced nav, that router will take over and now you're in a SPA.<Router/>
doesn't recognize, so it will do a full-page load. Then you need the matched endpoint to render an MPA page that does not have an interactive<Router/>
(so you can't use the same rootApp
component if that contains the interactive router).Temporary limitations
Until #48763 and #48765 are implemented, this does not fully integrate with interactive components. As a short-term stopgap for preview 6:
The result of this is that in preview 6, things will work, but won't keep using enhanced nav if you have any interactive components and will just fall back on full-page loads (unless you have an interactive router).