Make use of the list of Atoms in the class attribute in selector matching.

Fixes #3111