check if the toggle is in a list

This checks if the toggle is in a list before adding the classes. Without this the function adds the active class outside the scope of the toggle. Now if anything is in a list (also a button) the element that carries the active class will be the list element. If it is not in a list the element itself will carry the active class.