Add existence check for target.classList in click handler

I was doing some integration with d3 (SVG), and found
that target.classList was undefined in several cases.

Adding this check fixed the issue - thank you in advance
for your consideration!

-Sunny