be null-safe when checking `document.body.tagName`

fixes #1365