Fix Uncaught TypeError: Cannot read property 'length' of null

https://app.getsentry.com/id/id/group/5208581/
Fix Uncaught TypeError: Cannot call method 'getAttribute' of undefined

https://app.getsentry.com/id/id/group/5151824/