Fixes DOM exception caused by HtmlWriter.writeGridJavaScript.