states demo: 

not sure where onstatechange is coming from, probably some really old code that should actually go away?
If you're checking the type, there should be a typeof here too.