Issue 19131: changes to document.js from Mike