2 return document.createTextNode(text);
5 function element(elementName, attributesOrChildNodes, childNodes) {
6 var element = document.createElement(elementName);
8 if (attributesOrChildNodes instanceof Array)
9 childNodes = attributesOrChildNodes;
10 else if (attributesOrChildNodes) {
11 for (var attributeName in attributesOrChildNodes)
12 element.setAttribute(attributeName, attributesOrChildNodes[attributeName]);
16 for (var i = 0; i < childNodes.length; i++) {
17 if (childNodes[i] instanceof Node)
18 element.appendChild(childNodes[i]);
20 element.appendChild(document.createTextNode(childNodes[i]));