MCPcopy Create free account
hub / github.com/Samirla/xmlview / stylize

Function stylize

src/renderer.js:49–75  ·  view source on GitHub ↗

* Stylize DOM node * @param {HTMLElement} node Node to render * @param {Number} depth Depth level of child elements should be rendered * @return {String}

(node, depth)

Source from the content-addressed store, hash-verified

47 * @param {Number} depth Depth level of child elements should be rendered
48 * @return {String}
49 */
50 function stylize(node, depth) {
51 if (node) {
52 switch (node.nodeType) {
53 case 1: // element
54 return stylizeElement(node, depth);
55 case 3: // text node
56 return stylizeTextNode(node, depth);
57 case 4: // text node
58 return stylizeCDATA(node, depth);
59 case 7: // processing instruction
60 return stylizeProcessingInstruction(node, depth);
61 case 8: // comment
62 return stylizeComment(node, depth);
63 case 9: // document
64 var result = [];
65 for (var i = 0, il = node.childNodes.length; i < il; i++) {
66 result.push(stylize(node.childNodes[i], depth));
67 }
68 return result.join('');
69 default:
70 if (window.console)
71 console.log('processing unknown type:', node.nodeType);
72 }
73 }
74
75 return '';
76 }
77
78 /**

Callers 2

stylizeElementFunction · 0.70
renderer.jsFile · 0.70

Calls 5

stylizeTextNodeFunction · 0.85
stylizeElementFunction · 0.70
stylizeCDATAFunction · 0.70
stylizeCommentFunction · 0.70

Tested by

no test coverage detected