MCPcopy Create free account
hub / github.com/socketstream/socketstream / childContentWrapper

Function childContentWrapper

docs/js/google-code-prettify.js:597–608  ·  view source on GitHub ↗

* Given an element, if it contains only one child element and any text nodes * it contains contain only space characters, return the sole child element. * Otherwise returns undefined. * * This is meant to return the CODE element in when * there is a single

(element)

Source from the content-addressed store, hash-verified

595 * is textual content.
596 */
597 function childContentWrapper(element) {
598 var wrapper = undefined;
599 for (var c = element.firstChild; c; c = c.nextSibling) {
600 var type = c.nodeType;
601 wrapper = (type === 1) // Element Node
602 ? (wrapper ? element : c)
603 : (type === 3) // Text Node
604 ? (notWs.test(c.nodeValue) ? element : wrapper)
605 : wrapper;
606 }
607 return wrapper === element ? undefined : wrapper;
608 }
609
610 /** Given triples of [style, pattern, context] returns a lexing function,
611 * The lexing function interprets the patterns to find token boundaries and

Callers 1

doWorkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected