Skip to content

Commit 947a485

Browse files
authored
fix: Failed to fetch dynamically imported module #35 (#36)
* fix: Failed to fetch dynamically imported module #35 * fix: #35 make scriptPath relative
1 parent bc75326 commit 947a485

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/Ljbc1994.Blazor.IntersectionObserver/IntersectionObserverService.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Ljbc1994.Blazor.IntersectionObserver
1111
{
1212
public class IntersectionObserverService: IIntersectionObserverService, IAsyncDisposable
1313
{
14-
private readonly string scriptPath = "/_content/BlazorIntersectionObserver/blazor-intersection-observer.min.js";
14+
private readonly string scriptPath = "_content/BlazorIntersectionObserver/blazor-intersection-observer.min.js";
1515

1616
private readonly Task<IJSObjectReference> moduleTask;
1717

@@ -22,9 +22,10 @@ public class IntersectionObserverService: IIntersectionObserverService, IAsyncDi
2222
/// </summary>
2323
private readonly ConcurrentDictionary<string, IntersectionObserver> observers = new ConcurrentDictionary<string, IntersectionObserver>();
2424

25-
public IntersectionObserverService(IJSRuntime jsRuntime)
25+
public IntersectionObserverService(IJSRuntime jsRuntime, NavigationManager navManager)
2626
{
27-
this.moduleTask = jsRuntime.InvokeAsync<IJSObjectReference>("import", this.scriptPath).AsTask();
27+
var path = navManager.ToAbsoluteUri(this.scriptPath);
28+
this.moduleTask = jsRuntime.InvokeAsync<IJSObjectReference>("import", path).AsTask();
2829
this.objectRef = DotNetObjectReference.Create(this);
2930
}
3031

0 commit comments

Comments
 (0)