I am using MutationObserver and want to check a class selector on target.className
but I get an error
Cannot read properties of undefined (reading 'contains')
so I looked at classList's prototype and it has .contains
method and I did the following target.classList.prototype.contains("OverlayWrapper")
and I still get the same error.
I don't understand why I am getting this error as I am trying to check for a partial className
.
Edit: I have added a snapshot of the console
Edit: I have made an example for the code, it is the bare minimum where I am looking for a class that contains popUp__wrapper
being added to the DOM. (an error will be in the console when we press the open button) jsfiddle