Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4173

Make Blazor stay in sync with JS manipulated DOM

$
0
0

My problem is that I have a page which implements IDisposable interface, and when I move away from this page I get an error

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]Unhandled exception rendering component: TypeError: Cannot read properties of null (reading 'removeChild')

and also

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]Unhandled exception rendering component: Error: No element is currently associated with component 40

I have a search input which finds all occurrences of the input value on the entire page and highlights them. It works through JS Interop and uses a JS function which manipulates DOM (wraps all occurrences of the input value with <span class="highlight"></span>).

I've investigated that Blazor has its own in-memory DOM copy and my problem derives from the fact that it does not see changes that was made by JS. That elements seem unfamiliar to Blazor...

So, can I somehow make Blazor know the changes to DOM that are made by JS? Or maybe implement this feature of highlighting with pure Blazor (but note that I need to be able to search through the text of the entire page, like Ctrl+F in browser does)?


Viewing all articles
Browse latest Browse all 4173


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>