Skip to content

Commit 89c2573

Browse files
Fix JS interop cases in WebView (#31054)
1 parent cc33b22 commit 89c2573

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

src/Components/Web.JS/dist/Release/blazor.webview.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/src/Platform/WebView/WebViewIpcReceiver.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ export function startIpcReceiver() {
3131

3232
'BeginInvokeJS': DotNet.jsCallDispatcher.beginInvokeJSFromDotNet,
3333

34-
'EndInvokeDotNet': DotNet.jsCallDispatcher.endInvokeDotNetFromJS,
34+
'EndInvokeDotNet': (asyncCallId: string, success: boolean, invocationResultOrError: string) => {
35+
const resultOrExceptionMessage: any = DotNet.parseJsonWithRevivers(invocationResultOrError);
36+
DotNet.jsCallDispatcher.endInvokeDotNetFromJS(asyncCallId, success, resultOrExceptionMessage);
37+
},
3538

3639
'Navigate': navigationManagerFunctions.navigateTo,
3740
};

src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/webviewhost.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
<title>WinFormsTestApp</title>
88
<base href="/" />
99
<link href="css/app.css" rel="stylesheet" />
10+
11+
<!-- Used by ExternalContentPackage -->
12+
<link href="_content/TestContentPackage/styles.css" rel="stylesheet" />
13+
14+
<!-- App bundle that contains a reference to the scoped css bundle created by TestContentPackage -->
15+
<link href="WinFormsTestApp.styles.css" rel="stylesheet" />
1016
</head>
1117

1218
<body>

src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/wwwroot/webviewhost.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
<title>WinFormsTestApp</title>
88
<base href="/" />
99
<link href="css/app.css" rel="stylesheet" />
10+
11+
<!-- Used by ExternalContentPackage -->
12+
<link href="_content/TestContentPackage/styles.css" rel="stylesheet" />
13+
14+
<!-- App bundle that contains a reference to the scoped css bundle created by TestContentPackage -->
15+
<link href="WpfTestApp.styles.css" rel="stylesheet" />
1016
</head>
1117

1218
<body>

src/Components/WebView/WebView/src/IpcReceiver.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,7 @@ private void BeginInvokeDotNet(PageContext pageContext, string callId, string as
8282

8383
private void EndInvokeJS(PageContext pageContext, long asyncHandle, bool succeeded, string argumentsOrError)
8484
{
85-
if (succeeded)
86-
{
87-
DotNetDispatcher.EndInvokeJS(pageContext.JSRuntime, argumentsOrError);
88-
}
89-
else
90-
{
91-
throw new InvalidOperationException(argumentsOrError);
92-
}
85+
DotNetDispatcher.EndInvokeJS(pageContext.JSRuntime, argumentsOrError);
9386
}
9487

9588
private Task DispatchBrowserEventAsync(PageContext pageContext, string eventDescriptor, string eventArgs)

0 commit comments

Comments
 (0)