Skip to content

Fixup JS #21922

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

Merged
merged 2 commits into from
May 18, 2020
Merged

Fixup JS #21922

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Components/Shared/src/BrowserNavigationManagerInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ internal static class BrowserNavigationManagerInterop

public static readonly string EnableNavigationInterception = Prefix + "enableNavigationInterception";

public static readonly string GetLocationHref = Prefix + "getLocationHref";
public static readonly string GetLocationHref = Prefix + "getUnmarshalledLocationHref";

public static readonly string GetBaseUri = Prefix + "getBaseURI";
public static readonly string GetBaseUri = Prefix + "getUnmarshalledBaseURI";

public static readonly string NavigateTo = Prefix + "navigateTo";
}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Web.JS/dist/Release/blazor.server.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Components/Web.JS/dist/Release/blazor.webassembly.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/Components/Web.JS/src/Boot.WebAssembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ async function boot(options?: Partial<WebAssemblyStartOptions>): Promise<void> {
};

// Configure navigation via JS Interop
const getBaseUri = window['Blazor']._internal.navigationManager.getBaseURI;
const getLocationHref = window['Blazor']._internal.navigationManager.getLocationHref;
window['Blazor']._internal.navigationManager.getUnmarshalledBaseURI = () => BINDING.js_string_to_mono_string(getBaseUri());
window['Blazor']._internal.navigationManager.getUnmarshalledLocationHref = () => BINDING.js_string_to_mono_string(getLocationHref());

window['Blazor']._internal.navigationManager.listenForNavigationEvents(async (uri: string, intercepted: boolean): Promise<void> => {
await DotNet.invokeMethodAsync(
'Microsoft.AspNetCore.Components.WebAssembly',
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Web.JS/src/Services/NavigationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const internalFunctions = {
listenForNavigationEvents,
enableNavigationInterception,
navigateTo,
getBaseURI: () => BINDING.js_string_to_mono_string(document.baseURI),
getLocationHref: () => BINDING.js_string_to_mono_string(location.href),
getBaseURI: () => document.baseURI,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is common to the Server and WebAssembly, so we cannot do this here. Moving this to Boot.WebAssembly. Let me know if there's a better way to do this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why didn't we use document.baseURI in the past? Doesn't this change any expectation wherever this is used?

Copy link
Member

Choose a reason for hiding this comment

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

We did use document.baseURI in the past - see the old line 16.

getLocationHref: () => location.href,
};

function listenForNavigationEvents(callback: (uri: string, intercepted: boolean) => Promise<void>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '../src/GlobalExports';
import { UserSpecifiedDisplay } from '../src/Platform/Circuits/UserSpecifiedDisplay';
import { DefaultReconnectionHandler } from '../src/Platform/Circuits/DefaultReconnectionHandler';
import { NullLogger} from '../src/Platform/Logging/Loggers';
import { resolveOptions, ReconnectionOptions } from "../src/Platform/Circuits/BlazorOptions";
import { resolveOptions, ReconnectionOptions } from "../src/Platform/Circuits/CircuitStartOptions";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Old rename that had left this test broken

import { ReconnectDisplay } from '../src/Platform/Circuits/ReconnectDisplay';

const defaultReconnectionOptions = resolveOptions().reconnectionOptions;
Expand Down