MCPcopy Create free account
hub / github.com/Lucifier129/react-lite / createNodesFromMarkup

Function createNodesFromMarkup

examples/simple/react.js:17911–17939  ·  view source on GitHub ↗

* Creates an array containing the nodes rendered from the supplied markup. The * optionally supplied `handleScript` function will be invoked once for each * element that is rendered. If no `handleScript` function is supplied, * an exception is thrown if any elements are rendered

(markup, handleScript)

Source from the content-addressed store, hash-verified

17909 * @return {array<DOMElement|DOMTextNode>} An array of rendered nodes.
17910 */
17911function createNodesFromMarkup(markup, handleScript) {
17912 var node = dummyNode;
17913 !!!dummyNode ? "development" !== 'production' ? invariant(false, 'createNodesFromMarkup dummy not initialized') : invariant(false) : undefined;
17914 var nodeName = getNodeName(markup);
17915
17916 var wrap = nodeName && getMarkupWrap(nodeName);
17917 if (wrap) {
17918 node.innerHTML = wrap[1] + markup + wrap[2];
17919
17920 var wrapDepth = wrap[0];
17921 while (wrapDepth--) {
17922 node = node.lastChild;
17923 }
17924 } else {
17925 node.innerHTML = markup;
17926 }
17927
17928 var scripts = node.getElementsByTagName('script');
17929 if (scripts.length) {
17930 !handleScript ? "development" !== 'production' ? invariant(false, 'createNodesFromMarkup(...): Unexpected <script> element rendered.') : invariant(false) : undefined;
17931 createArrayFromMixed(scripts).forEach(handleScript);
17932 }
17933
17934 var nodes = createArrayFromMixed(node.childNodes);
17935 while (node.lastChild) {
17936 node.removeChild(node.lastChild);
17937 }
17938 return nodes;
17939}
17940
17941module.exports = createNodesFromMarkup;
17942},{"129":129,"133":133,"139":139,"143":143}],135:[function(_dereq_,module,exports){

Callers 1

react.jsFile · 0.85

Calls 4

getNodeNameFunction · 0.85
getMarkupWrapFunction · 0.85
createArrayFromMixedFunction · 0.85
invariantFunction · 0.70

Tested by

no test coverage detected