FIX: Uncaught TypeError: Cannot call method 'shift' of undefined

This was discovered in Discourse. The fix is a simple `if` check to see if a variable is defined. Tests provided.

see https://meta.discourse.org/t/js-exception-in-composer-method-shift/14589