Fix a fatal error due to cloning a global document object