Skip to content

Commit

Permalink
[automated] Merge branch 'release/8.0-rc2' => 'release/8.0' (#50823)
Browse files Browse the repository at this point in the history
* Handle obsolete InterceptorsPreview with .NET 8 RC2 SDK (#50797)

* Quarantine (actually comment out) one of the CanRenderComponentWithPersistedState cases (#50811)

See dotnet/aspnetcore#50810

* Stop processing original response streaming content if user has started navigating away (#50814)

* Reproduce #50733 as a failing E2E test

* Don't process original request blazor-ssr content if the user has already navigated away

* Quarantine (actually comment out) one of the CanRenderComponentWithPersistedState cases

See dotnet/aspnetcore#50810

* Update EventTest.cs

* Disable another flaky test

---------

Co-authored-by: Matt Thalman <mthalman@microsoft.com>
Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 20, 2023
1 parent 050e8d5 commit da4d8a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/Release/blazor.web.js

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/Rendering/StreamingRendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

import { SsrStartOptions } from '../Platform/SsrStartOptions';
import { NavigationEnhancementCallbacks, performEnhancedPageLoad, replaceDocumentWithPlainText } from '../Services/NavigationEnhancement';
import { NavigationEnhancementCallbacks, hasNeverStartedAnyEnhancedPageLoad, performEnhancedPageLoad, replaceDocumentWithPlainText } from '../Services/NavigationEnhancement';
import { isWithinBaseUriSpace, toAbsoluteUri } from '../Services/NavigationUtils';
import { synchronizeDomContent } from './DomMerging/DomSync';

Expand Down Expand Up @@ -36,7 +36,14 @@ class BlazorStreamingUpdate extends HTMLElement {
if (node instanceof HTMLTemplateElement) {
const componentId = node.getAttribute('blazor-component-id');
if (componentId) {
insertStreamingContentIntoDocument(componentId, node.content);
// For enhanced nav page loads, we automatically cancel the response stream if another enhanced nav supersedes it. But there's
// no way to cancel the original page load. So, to avoid continuing to process <blazor-ssr> blocks from the original page load
// if an enhanced nav supersedes it, we must explicitly check whether this content is from the original page load, and if so,
// ignore it if any enhanced nav has started yet. Fixes https://github.com/dotnet/aspnetcore/issues/50733
const isFromEnhancedNav = node.getAttribute('enhanced-nav') === 'true';
if (isFromEnhancedNav || hasNeverStartedAnyEnhancedPageLoad()) {
insertStreamingContentIntoDocument(componentId, node.content);
}
} else {
switch (node.getAttribute('type')) {
case 'redirection':
Expand Down
4 changes: 4 additions & 0 deletions src/Services/NavigationEnhancement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export function isPageLoading() {
return performingEnhancedPageLoad || document.readyState === 'loading';
}

export function hasNeverStartedAnyEnhancedPageLoad() {
return !currentEnhancedNavigationAbortController;
}

export function attachProgressivelyEnhancedNavigationListener(callbacks: NavigationEnhancementCallbacks) {
navigationEnhancementCallbacks = callbacks;
document.addEventListener('click', onDocumentClick);
Expand Down

0 comments on commit da4d8a8

Please sign in to comment.