Be more defensive about whether the new widget is a document.
Be more defensive about whether the new widget is a document.

jupyter/jupyterlab,jupyter/jupyterlab,jupyter/jupyterlab,jupyter/jupyterlab,jupyter/jupyterlab