DOM Level 2対応でないブラウザ (具体的にはMSIE 6.0) のために書いているJavaScript版document.importNodeの作りかけコード。だれか使う?
if (document.importNode == undefined)
{
/* For DOM Level 1: */
document.importNode = function (node, deep)
{
if (node == null)
{
return null;
}
var value;
switch (node.nodeType)
{
case 1: /* Node.ELEMENT_NODE */
value = document.createElement (node.nodeName);
/** @todo attributes */
if (deep)
{
for (var i = node.firstChild; i != null; i = i.nextSibling)
{
value.appendChild (document.importNode (i, true));
}
}
break;
case 3: /* Node.TEXT_NODE */
value = document.createTextNode (node.nodeValue);
break;
case 4: /* Node.CDATA_SECTION_NODE */
value = document.createCDATASection (node.nodeValue);
break;
case 8: /* Node.COMMENT_NODE */
value = document.createComment (node.nodeValue);
break;
default:
window.alert ("Unexpected node");
value = document.createComment ("Unexpected node");
break;
}
return value;
};
}