我有一些代码执行XSLT转换,将结果追加到element1,清除element2中的内容,然后将内容从element1交换到element2。非常感谢任何关于可能出错的指示!
function transformAndUpdate(contentDocument, xsltDocument, placeHolder)
{
var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsltDocument);
var resultFragment = xsltProcessor.transformToFragment(contentDocument, document);
if (placeHolder != null)
{
var GC = document.getElementById("garbageCollector");
GC.appendChild(resultFragment);
placeHolder.innerHTML = "";
while (GC.childNodes.length)
placeHolder.appendChild(GC.childNodes[0]);
/* this leaks also if used instead of while loop
placeHolder.innerHTML = GC.innerHTML;*/
GC.innerHTML = "";
GC = null;
}
xsltProcessor = null;
resultFragment = null;
}
我做错了什么? XSLT转换生成的DOM上没有事件处理程序,它只是一个包含多个表的大型DOM结构。
我发现以下代码没有泄漏,以证明它与转换无关。
function transformAndUpdate(contentDocument, xsltDocument, placeHolder)
{
var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsltDocument);
var resultFragment = xsltProcessor.transformToFragment(contentDocument, document);
if (placeHolder != null)
{
placeHolder.innerHTML = "";
placeHolder.appendChild(resultFragment);
}
xsltProcessor = null;
resultFragment = null;
}