Skip to content

Commit

Permalink
🐛 fix(InfiniteScroll): crashes when the parent element doesn't exist (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem authored Jul 23, 2024
1 parent c4ba565 commit 3ab4af9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/Masa.Blazor.JS/src/interop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,11 @@ export function checkIfThresholdIsExceededWhenScrolling(el: Element, parent: any
parentElement = document.querySelector(parent);
}

if (!parentElement) {
console.warn('[MInfiniteScroll] failed to get parent element with selector:', parent);
return;
}

const rect = el.getBoundingClientRect();
const elementTop = rect.top;
const current = isWindow(parentElement)
Expand Down
2 changes: 1 addition & 1 deletion src/Masa.Blazor/JSInterop/JsInteropConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static class JsInteropConstants

public static string GetElementTranslateY => $"{JsInteropFuncNamePrefix}getElementTranslateY";

public static string CheckIfThresholdIsExceededWhenScrolling => $"{JsInteropFuncNamePrefix}checkIfThresholdIsExceededWhenScrolling";
internal static string CheckIfThresholdIsExceededWhenScrolling => $"{JsInteropFuncNamePrefix}checkIfThresholdIsExceededWhenScrolling";

public static string SetProperty => $"{JsInteropFuncNamePrefix}setProperty";

Expand Down
2 changes: 1 addition & 1 deletion src/Masa.Blazor/wwwroot/js/masa-blazor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Masa.Blazor/wwwroot/js/masa-blazor.js.map

Large diffs are not rendered by default.

0 comments on commit 3ab4af9

Please sign in to comment.