Update document.js

same problem as @KyleAMathews. but his change does not actually fix the problem.