Skip to content
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

[draft] JavaScript interop via [JSImport] and [JSExport] #41665

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public async Task EnableNavigationInterceptionAsync()
"attempted during prerendering or while the client is disconnected.");
}

await _jsRuntime.InvokeAsync<object>(Interop.EnableNavigationInterception);
await _jsRuntime.InvokeAsync<object>(Interop.EnableNavigationInterceptionName);
}
}
17 changes: 12 additions & 5 deletions src/Components/Shared/src/BrowserNavigationManagerInterop.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.InteropServices.JavaScript;

namespace Microsoft.AspNetCore.Components.Web;

// Shared interop constants
internal static class BrowserNavigationManagerInterop
internal static partial class BrowserNavigationManagerInterop
{
private const string Prefix = "Blazor._internal.navigationManager.";

public const string EnableNavigationInterception = Prefix + "enableNavigationInterception";
public const string EnableNavigationInterceptionName = Prefix + "enableNavigationInterception";

public const string NavigateTo = Prefix + "navigateTo";

public const string GetLocationHref = Prefix + "getUnmarshalledLocationHref";
[JSImport(EnableNavigationInterceptionName)]
public static partial void EnableNavigationInterception();

public const string GetBaseUri = Prefix + "getUnmarshalledBaseURI";
[JSImport(Prefix + "getLocationHref")]
public static partial string GetLocationHref();

public const string NavigateTo = Prefix + "navigateTo";
[JSImport(Prefix + "getBaseUri")]
public static partial string GetBaseUri();
}
Loading