Skip to content

Commit b6b06f6

Browse files
committed
minor
1 parent e6e5620 commit b6b06f6

File tree

1 file changed

+6
-6
lines changed
  • 2-ui/2-events/01-introduction-browser-events

1 file changed

+6
-6
lines changed

2-ui/2-events/01-introduction-browser-events/article.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ button.onclick = sayThanks();
162162

163163
If we add parentheses, `sayThanks()` -- is a function call. So the last line actually takes the *result* of the function execution, that is `undefined` (as the function returns nothing), and assigns it to `onclick`. That doesn't work.
164164

165-
...But in the markup we do need the parentheses:
165+
...On the other hand, in the markup we do need the parentheses:
166166

167167
```html
168168
<input type="button" id="button" onclick="sayThanks()">
169169
```
170170

171-
The difference is easy to explain. When the browser reads the attribute, it creates a handler function with the body from its content.
171+
The difference is easy to explain. When the browser reads the attribute, it creates a handler function with *body from its content*: `sayThanks()`.
172172

173-
So the last example is the same as:
173+
So the markup generates this property:
174174
```js
175175
button.onclick = function() {
176176
*!*
@@ -351,7 +351,7 @@ Some properties of `event` object:
351351
: Event type, here it's `"click"`.
352352
353353
`event.currentTarget`
354-
: Element that handled the event. That's exactly the same as `this`, unless the handler is an arrow function, or its `this` is bound to something else, then `event.currentTarget` becomes useful.
354+
: Element that handled the event. That's exactly the same as `this`, unless the handler is an arrow function, or its `this` is bound to something else, then we can get the element from `event.currentTarget`.
355355
356356
`event.clientX / event.clientY`
357357
: Window-relative coordinates of the cursor, for mouse events.
@@ -371,7 +371,7 @@ That's possible because when the browser reads the attribute, it creates a handl
371371

372372
## Object handlers: handleEvent
373373

374-
We can assign an object as an event handler using `addEventListener`. When an event occurs, its `handleEvent` method is called with it.
374+
We can assign not just a function, but an object as an event handler using `addEventListener`. When an event occurs, its `handleEvent` method is called.
375375

376376
For instance:
377377

@@ -388,7 +388,7 @@ For instance:
388388
</script>
389389
```
390390

391-
In other words, when `addEventListener` receives an object as the handler, it calls `object.handleEvent(event)` in case of an event.
391+
As we can see, when `addEventListener` receives an object as the handler, it calls `object.handleEvent(event)` in case of an event.
392392

393393
We could also use a class for that:
394394

0 commit comments

Comments
 (0)