Crazy JS error makes no sense

This makes no sense:

It seems to have a problem because I’m removing the ‘box’ class. If I added other classes I can remove them, but not the ‘box’ one.

Error: TypeError: ele is undefined
Source File:
Line: 58

function hasClass(ele,cls) {
	return ele.className.match(new RegExp('(\\\\s|^)'+cls+'(\\\\s|$)'));

I’ve never seen regex with “whitespace” or “beginning” … “whitespace” or “end” written like that.
Maybe try


“beginning” maybe “whitespace” … maybe “whitespace” “end”