function getPlayButton(el) {
while (!el.classList.matches(selector)) {
el = el.parentNode;
}
return el;
}
function playButtonClickHandler(evt) {
var button = getPlayButton(evt.target);
togglePlayButton(button);
}
var playButton = document.querySelector(".playButton");
playButton.addEventListener("click", playButtonClickHandler);
}());
Do you see how the getPlayButton function has only el as a parameter to that function, and that selector is also used inside that function?
You need to either:
change selector to a string value of what you’re wanting to match, or
if you want the function to be able to match any given selector, you need to change that function to be the upTo() function that we’ve used elsewhere instead.
Well that would be going back to using matches("playButton") but that would be mean that you are making backwards progress instead of forwards progress.
You certainly could keep the upTo() function in there, and with the match() and noMatch functions above the upTo() function, you could make use of it by updating the condition of the while loop:
function upTo(el, selector) {
while (noMatch(el, selector)) {
el = el.parentNode;
}
return el;
}