Check for the existence of document before accessing it.

Since `document` is referenced within `getDefaultProps` which unlike `componentDidMount` is run in both browser and node environments we need to make sure we check it exists before accessing it.