Problem with string cast
First of all, I want to really thank you for this script, it is a really nice one :D
It seems that the variable elem.className is not anymore considerate naturally as a string
var elemClasses = elem.className.split(' ');
And it is necessary to cast it to a string with toString method :
var elemClasses = elem.className.toString().split(' ');
I do not know exactly why, but I noticed it with chrome console.
Thanks for your attention.