wrapping element attribute assignments in null check

I've run into cases where the dom is ripped out from under chosen, and if there are any lingering callbacks that attempt to alter chosen's options etc., errors are thrown since the elements may no longer exist.

In the cases I've run into, the issue is probably that the application code needs to be updated to be aware of the dom getting ripped out and not attempt to update the chosen objects.  Even so, this seems like a good null check to have.