closes #1852
This commit is contained in:
parent
f0bd80c5ce
commit
ba88b60f63
1 changed files with 2 additions and 2 deletions
|
@ -101,8 +101,8 @@ table.onclick = function(event) {
|
||||||
|
|
||||||
Explanations:
|
Explanations:
|
||||||
1. The method `elem.closest(selector)` returns the nearest ancestor that matches the selector. In our case we look for `<td>` on the way up from the source element.
|
1. The method `elem.closest(selector)` returns the nearest ancestor that matches the selector. In our case we look for `<td>` on the way up from the source element.
|
||||||
2. If `event.target` is not inside any `<td>`, then the call returns `null`, and we don't have to do anything.
|
2. If `event.target` is not inside any `<td>`, then the call returns immediately, as there's nothing to do.
|
||||||
3. In case of nested tables, `event.target` may be a `<td>` lying outside of the current table. So we check if that's actually *our table's* `<td>`.
|
3. In case of nested tables, `event.target` may be a `<td>`, but lying outside of the current table. So we check if that's actually *our table's* `<td>`.
|
||||||
4. And, if it's so, then highlight it.
|
4. And, if it's so, then highlight it.
|
||||||
|
|
||||||
As the result, we have a fast, efficient highlighting code, that doesn't care about the total number of `<td>` in the table.
|
As the result, we have a fast, efficient highlighting code, that doesn't care about the total number of `<td>` in the table.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue