Skip to content

Commit 9aa18df

Browse files
committed
Merge branch 'master' of github.com:javascript-tutorial/en.javascript.info into sync-79417c6e
2 parents d27b611 + 79417c6 commit 9aa18df

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

2-ui/2-events/03-event-delegation/article.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ The handler reads the attribute and executes the method. Take a look at the work
163163

164164
Please note that `this.onClick` is bound to `this` in `(*)`. That's important, because otherwise `this` inside it would reference the DOM element (`elem`), not the `Menu` object, and `this[action]` would not be what we need.
165165

166-
So, what the delegation gives us here?
166+
So, what advantages does delegation give us here?
167167

168168
```compare
169169
+ We don't need to write the code to assign a handler to each button. Just make a method and put it in the markup.
@@ -242,13 +242,13 @@ That may become really convenient -- no need to write JavaScript for every such
242242

243243
We can combine multiple behaviors on a single element as well.
244244

245-
The "behavior" pattern can be an alternative of mini-fragments of JavaScript.
245+
The "behavior" pattern can be an alternative to mini-fragments of JavaScript.
246246

247247
## Summary
248248

249249
Event delegation is really cool! It's one of the most helpful patterns for DOM events.
250250

251-
It's often used to add same handling for many similar elements, but not only for that.
251+
It's often used to add the same handling for many similar elements, but not only for that.
252252

253253
The algorithm:
254254

@@ -261,12 +261,12 @@ Benefits:
261261
```compare
262262
+ Simplifies initialization and saves memory: no need to add many handlers.
263263
+ Less code: when adding or removing elements, no need to add/remove handlers.
264-
+ DOM modifications: we can mass add/remove elements with `innerHTML` and alike.
264+
+ DOM modifications: we can mass add/remove elements with `innerHTML` and the like.
265265
```
266266

267267
The delegation has its limitations of course:
268268

269269
```compare
270270
- First, the event must be bubbling. Some events do not bubble. Also, low-level handlers should not use `event.stopPropagation()`.
271-
- Second, the delegation may add CPU load, because the container-level handler reacts on events in any place of the container, no matter if they interest us or not. But usually the load is negligible, so we don't take it into account.
271+
- Second, the delegation may add CPU load, because the container-level handler reacts on events in any place of the container, no matter whether they interest us or not. But usually the load is negligible, so we don't take it into account.
272272
```

0 commit comments

Comments
 (0)