Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f90b47b

Browse filesBrowse files
authored
Fix JS error on resize (#328)
1 parent 7e48906 commit f90b47b
Copy full SHA for f90b47b

File tree

Expand file treeCollapse file tree

1 file changed

+13
-7
lines changed
Filter options
  • sample-applications/blazor-financial-dashboard/BlazorFinancialDashboard/wwwroot
Expand file treeCollapse file tree

1 file changed

+13
-7
lines changed

‎sample-applications/blazor-financial-dashboard/BlazorFinancialDashboard/wwwroot/app.js

Copy file name to clipboardExpand all lines: sample-applications/blazor-financial-dashboard/BlazorFinancialDashboard/wwwroot/app.js
+13-7Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ viewPortResizeObserver = {
1313
},
1414

1515
addComponent: function(dotNetRef) {
16-
if (viewPortResizeObserver.dotNetRefs.indexOf(dotNetRef) < 0) {
16+
let shouldAddComponent = true;
17+
18+
viewPortResizeObserver.dotNetRefs.forEach(x => {
19+
if (x._id == dotNetRef._id) {
20+
shouldAddComponent = false;
21+
}
22+
});
23+
24+
if (shouldAddComponent) {
1725
viewPortResizeObserver.dotNetRefs.push(dotNetRef);
1826
}
1927
},
@@ -22,18 +30,16 @@ viewPortResizeObserver = {
2230
clearTimeout(viewPortResizeObserver.timeoutId);
2331

2432
viewPortResizeObserver.timeoutId = window.setTimeout(function() {
25-
viewPortResizeObserver.dotNetRefs.forEach((dotNetRef) => {
33+
viewPortResizeObserver.dotNetRefs.forEach(dotNetRef => {
2634
dotNetRef.invokeMethodAsync(viewPortResizeObserver.serverMethodName);
2735
});
2836
}, viewPortResizeObserver.resizeDebounceDelay);
2937
},
3038

3139
removeComponent: function(dotNetRef) {
32-
let idx = viewPortResizeObserver.dotNetRefs.indexOf(dotNetRef);
33-
34-
if (idx >= 0) {
35-
viewPortResizeObserver.dotNetRefs.splice(idx, 1);
36-
}
40+
viewPortResizeObserver.dotNetRefs = viewPortResizeObserver.dotNetRefs.filter(x => {
41+
return x._id != dotNetRef._id;
42+
});
3743
},
3844

3945
destroy() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.