Commit bc36f03
authored
FIX: prevents scroll-lock to crash the app (#36246)
In rare cases, especially on mobile, we could end up in a situation
where `null` is given to `unlockScroll`, we were given a default arg to
the function through: `unlockScroll(element =
document.scrollingElement)` but this is working only if the given
element is `undefined` and not `null` resulting sometimes in the
following error:
```js
TypeError: null is not an object (evaluating 'element.classList')
```
Following this error, the whole UI would become unresponsive.
Here is a simple example to demonstrate the buggy behavior here:
```js
function greet(name = "World") {
console.log(`Hello, ${name}!`);
}
greet(); // Hello, World! ✓ (default applied)
greet(undefined); // Hello, World! ✓ (default applied)
greet(null); // Hello, null! ✗ (default NOT applied!)
```1 parent 9a4d5d9 commit bc36f03
1 file changed
+12
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
| |||
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
18 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
19 | 29 | | |
20 | 30 | | |
21 | 31 | | |
| |||
0 commit comments