Completing the `add class` snippet

There are two problems with the current suggestion of adding a new class under IE:

a) If there is no class assigned so far the new one is added with an interval infront. I.e. it looks `class=" my-class"` and not `class="my-class"`.
b) There is no check if the class is already added

Here is a jsbin with the new version: http://jsbin.com/lajuh/2/edit