minor fixes
This commit is contained in:
parent
c2ce2d4cbd
commit
b4910970c2
2 changed files with 4 additions and 4 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
[recent browser="new"]
|
||||
|
||||
The optional chaining `?.` is an error-prone way to access nested object properties, even if an intermediate property doesn't exist.
|
||||
The optional chaining `?.` is an error-proof way to access nested object properties, even if an intermediate property doesn't exist.
|
||||
|
||||
## The problem
|
||||
|
||||
|
@ -40,7 +40,7 @@ AND'ing the whole path to the property ensures that all components exist, but is
|
|||
|
||||
The optional chaining `?.` stops the evaluation and returns `undefined` if the part before `?.` is `undefined` or `null`.
|
||||
|
||||
Further in this article, for brewity, we'll be saying that something "exists" if it's not `null` and not `undefined`.
|
||||
Further in this article, for brevity, we'll be saying that something "exists" if it's not `null` and not `undefined`.
|
||||
|
||||
|
||||
Here's the safe way to access `user.address.street`:
|
||||
|
|
|
@ -243,9 +243,9 @@ The output order is: 1 -> nested -> 2.
|
|||
|
||||
Please note that the nested event `menu-open` is caught on the `document`. The propagation and handling of the nested event is finished before the processing gets back to the outer code (`onclick`).
|
||||
|
||||
That's not only about `dispatchEvent`, there are other cases. If an event handler calls methods that trigger to other events -- they are too processed synchronously, in a nested fasion.
|
||||
That's not only about `dispatchEvent`, there are other cases. If an event handler calls methods that trigger to other events -- they are too processed synchronously, in a nested fashion.
|
||||
|
||||
Let's say we don't like it. We'd want `onclick` to be fully processed first, independantly from `menu-open` or any other nested events.
|
||||
Let's say we don't like it. We'd want `onclick` to be fully processed first, independently from `menu-open` or any other nested events.
|
||||
|
||||
Then we can either put the `dispatchEvent` (or another event-triggering call) at the end of `onclick` or, maybe better, wrap it in the zero-delay `setTimeout`:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue