I don’t need this anymore?
function upTo(el, selector) {
while (el.matches(selector) === false) {
el = el.parentNode;
}
return el;
}
I don’t need this anymore?
function upTo(el, selector) {
while (el.matches(selector) === false) {
el = el.parentNode;
}
return el;
}
Nope, not at all. That was only to get from a deeper element (like the pause icon) up to the playButton, which is a task that’s no longer needed. JSLint is correct about it no longer being used. Get rid of it.
This won’t work
without it? Right
buttons.forEach(function hidePause(button) {
function pauseAllButtons() {
var buttons = document.querySelectorAll(".playButton");
buttons.forEach(function hidePause(button) {
if (isPlaying()) {
showPlayButton();
}
});
}
It said to get rid of button
and it’s correct.
Explain why I don’t need it anymore please.
Before:
After deleting line:
buttons.forEach(function hidePause(button)
Broken
What did I do wrong?
The showPlayButton() function used to use it, but it no longer needs it, because the var button
at the top is what is uses for the button (or the wrapper).
Because showPlayButton() no longer uses an explicit argument of button
, the hidePause() function doesn’t need to supply it either.
What you did wrong was to delete the whole line.
What was I supposed to do?
This?
buttons.forEach(function hidePause() {
I would just delete the evt from this one, right?
function playButtonClickHandler(evt) {
Yes that’s right.
It’s all good now.
It sure would have been hard to find that unneeded stuff without using a linter.
I would have never noticed it.
Now I use it every time before I save a code.
Why is it important to have a unique class or identifier on the element?
As preparation for when other buttons are there.
Other buttons, as in what?
So that they can all tell each other apart.
That’s right.