Crazy JS error makes no sense

This makes no sense:

http://page-test.co.uk/a.html

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: http://page-test.co.uk/a.html
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

RegExp('^(\\\\s)?'+cls+'(\\\\s)?$'));

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