diff --git a/src/Components/WebView/WebView/src/PageContext.cs b/src/Components/WebView/WebView/src/PageContext.cs index 4ab64181c886..e2f88ce88225 100644 --- a/src/Components/WebView/WebView/src/PageContext.cs +++ b/src/Components/WebView/WebView/src/PageContext.cs @@ -42,7 +42,7 @@ public PageContext( JSRuntime.AttachToWebView(ipcSender); var loggerFactory = services.GetRequiredService(); - Renderer = new WebViewRenderer(services, dispatcher, ipcSender, loggerFactory); + Renderer = new WebViewRenderer(services, dispatcher, ipcSender, loggerFactory, JSRuntime.ElementReferenceContext); } public void Dispose() diff --git a/src/Components/WebView/WebView/src/Services/WebViewJSRuntime.cs b/src/Components/WebView/WebView/src/Services/WebViewJSRuntime.cs index d3a338310369..bb6b46ee6b6c 100644 --- a/src/Components/WebView/WebView/src/Services/WebViewJSRuntime.cs +++ b/src/Components/WebView/WebView/src/Services/WebViewJSRuntime.cs @@ -8,8 +8,11 @@ internal class WebViewJSRuntime : JSRuntime { private IpcSender _ipcSender; + public ElementReferenceContext ElementReferenceContext { get; } + public WebViewJSRuntime() { + ElementReferenceContext = new WebElementReferenceContext(this); JsonSerializerOptions.Converters.Add( new ElementReferenceJsonConverter( new WebElementReferenceContext(this))); diff --git a/src/Components/WebView/WebView/src/Services/WebViewRenderer.cs b/src/Components/WebView/WebView/src/Services/WebViewRenderer.cs index b9fbf6bee594..80b0a1b0a6af 100644 --- a/src/Components/WebView/WebView/src/Services/WebViewRenderer.cs +++ b/src/Components/WebView/WebView/src/Services/WebViewRenderer.cs @@ -22,11 +22,13 @@ public WebViewRenderer( IServiceProvider serviceProvider, Dispatcher dispatcher, IpcSender ipcSender, - ILoggerFactory loggerFactory) : + ILoggerFactory loggerFactory, + ElementReferenceContext elementReferenceContext) : base(serviceProvider, loggerFactory) { _dispatcher = dispatcher; _ipcSender = ipcSender; + ElementReferenceContext = elementReferenceContext; } public override Dispatcher Dispatcher => _dispatcher;