chanan/BlazorStrap

JSException at addEventListener

EMaderbacher opened this issue · 2 comments

When I'm clicking fast through pages with a tooltip I get sometimes this exception:

Microsoft.JSInterop.JSException: Cannot read properties of null (reading 'addEventListener')
TypeError: Cannot read properties of null (reading 'addEventListener')
    at Object.AddEventInternal (https://.../_content/BlazorStrap/blazorStrap.js:291:21)
    at https://.../_content/BlazorStrap/blazorStrap.js:295:25
    at new Promise (<anonymous>)
    at Object.AddEvent (https://.../_content/BlazorStrap/blazorStrap.js:294:16)
    at https://.../_framework/blazor.server.js:1:3501
    at new Promise (<anonymous>)
    at kt.beginInvokeJSFromDotNet (https://.../_framework/blazor.server.js:1:3475)
    at https://.../_framework/blazor.server.js:1:72077
    at Array.forEach (<anonymous>)
    at kt._invokeClientMethod (https://.../_framework/blazor.server.js:1:72063)
   at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, CancellationToken cancellationToken, Object[] args)
   at BlazorStrap.Shared.Components.Common.BSTooltipBase.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Reason is, that parameter element of function AddEventInternal is null.
Are there any side effects adding a null check at begin of function AddEventInternal?
image

No, if it's getting null the event isn't hooking right anyways. Need to figure out what might be causing it but it's safe to put the null check in the javascript

I guess reason is because of the async invocation of Javascript