Commit a317a79
committed
Check for handler presence before invoking it
If a waypoint unmounts another waypoint as part of handling an
onEnter/onLeave, and the two waypoints are attached to the same
scrollable ancestor, we could end up with this error:
Uncaught TypeError: handlers[index] is not a function
Consider the following example, where the first handler removes the
second:
```js
const a = {}
a.handlers = {
1: function() {
delete a.handlers[2];
},
2: function() {},
};
Object.keys(a.handlers).forEach(function(index) {
a.handlers[index]();
});
// => Uncaught TypeError: a.handlers[index] is not a function(…)
```
Adding a guard against undefined handlers fixes the problem. Testing
this turned out to be quite hard, so for now I'm just rolling with a
manual fix.1 parent 6ce28c6 commit a317a79
1 file changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
0 commit comments