only call addClass/removeClass on icon when icon defined

In certain instances, the icon was not being found and javascript was throwing an error "cannot call method addClass/removeClass of undefined".