Use setAttribute("class") instead of className.

Fixes #1112.
Merge branch 'avoid-className' into 3.1.0