Skip to content

Commit 4c7c1b7

Browse files
Update WebViewJSRuntime.cs (#40943)
1 parent 759dc45 commit 4c7c1b7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Components/WebView/WebView/src/Services/WebViewJSRuntime.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public void AttachToWebView(IpcSender ipcSender)
3030

3131
protected override void BeginInvokeJS(long taskId, string identifier, string argsJson, JSCallResultType resultType, long targetInstanceId)
3232
{
33+
if (_ipcSender is null)
34+
{
35+
throw new InvalidOperationException("Cannot invoke JavaScript outside of a WebView context.");
36+
}
37+
3338
_ipcSender.BeginInvokeJS(taskId, identifier, argsJson, resultType, targetInstanceId);
3439
}
3540

0 commit comments

Comments
 (0)