fixed issue where extra spaces added to class attr

when ever a class was added to a node, regardless of if a space was present at the end of the class attribute an additional one was added to ensure the new class was not appended to the end of the last class. This caused an ever increasing amount of spaces in the class attribute. Updated the addClass function to trim the current value of the class attribute, append a space and then append the new class