Transform a collection of nodes into an iframe version of themselves
including all the styles they need to perform correctly.

@param  {HTMLElement} nodes
@param  {Object} options
@return undefined
350564
function iframify (node, options) {
    options = getOptions(options);

    var iframe = document.createElement('iframe');
    var html = getIframeContentForNode(node, options);
    iframe.srcdoc = html;

    if (!('srcdoc' in iframe)) {
      console.log(
        'Your browser does not support the `srcdoc` attribute on elements.' +
        'Therefore, it is not possible to wrap this node with an iframe due' +
        'to CORS policy.'
      );

      return null;
    }

    node.parentNode.replaceChild(iframe, node);

    setTimeout(function () {
      var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
      iframe.height = getDocumentHeight(iframeDocument);
    }, options.sizingTimeout);

    return iframe;
  }
677681
function child_nodes(node) {
  var properties = NODE_TYPES[node["type"]];

  if (properties === undefined) {
    console.error("FATAL".red + ": Unknown node type: " + node["type"]);
    console.trace();
    process.exit(1);
  }

   var x = properties.map(function(p) {
     return node[p];
   });

   return _.flatten(_.compact(x));
}
538244
function(tag, nodes) {
    var xmlNodes = nodes.map(function(x) {return x.xml(xml, opt_brief);});
    var tagNode = xml.createElementNS('', tag);
    for (var i = 0, child; child = xmlNodes[i]; i++) {
      tagNode.appendChild(child);
    }
    return tagNode;
  }
488273
function transform(options, ast, cb) {

  var transformObj = {
    options: options
  };

  function queueNodeWalk(node, cb) {
    if (options._walkQueue) {
      options._walkQueue.push(node);
    }
  }

  function eachNodeRule(node, rule) {
    if (rule.transform) {
      if (typeof rule.transform === 'function') {
        node._walk = queueNodeWalk;
        rule.transform(node, transformObj);
        delete node._walk;
      }
    }
  }

  var rules = u.toArray(options.transform || 'default');

  nast.walkWithRules(options, rules, 'transform', ast, eachNodeRule, cb);
}
254773
function processMultipartNode(node, options) {
    options = options || {};

    var data = (node.childNodes && node.childNodes.map(function(tree) {
        return createBodystructure(tree, options);
    }) || [[]]).
        concat([
            // body subtype
            options.upperCaseKeys ? node.multipart && node.multipart.toUpperCase() || null : node.multipart,
            // body parameter parenthesized list
            node.parsedHeader['content-type'] &&
                node.parsedHeader['content-type'].hasParams &&
                flatten(Object.keys(node.parsedHeader['content-type'].params).map(function(key) {
                    return [
                        options.upperCaseKeys ? key.toUpperCase() : key,
                        node.parsedHeader['content-type'].params[key]];
                })) || null]);

    if (options.body) {
        return data;
    } else {
        return data.
            // skip body MD5 from extension fields
            concat(getExtensionFields(node, options).slice(1));
    }
}
1050717
function _updateNodes(nodes, source) {
  // Enter any new nodes at the parent's previous position.
  nodes.enter().append('g')
    .attr('transform', function(d) {
      var node = _getVertexNode(d, "x0") || source;
      node = _layout.projector(node.x0, node.y0);
      return 'translate(' + node.x + ',' + node.y + ')';
    })
    .on({
      mouseover: _onMouseOver,
      mouseout: _tip.hide,
      mousedown: _onMouse,
      mousemove: _onMouse,
      dblclick: _onDblclick
    })
    .style('opacity', 1e-6)
    .each(_addContent);

  // Transition nodes to their new position.
  nodes.transition()
    .duration(DURATION)
    .attr('transform', function(d) {
      d = _layout.projector(d.x, d.y);
      return 'translate(' + d.x + ',' + d.y + ')';
    })
    .style('opacity', 1);

  // Transition exiting nodes to the parent's new position.
  nodes.exit().transition()
    .duration(DURATION)
    .attr('transform', function(d) {
      var node = _getVertexNode(d, "x") || source;
      node = _layout.projector(node.x, node.y);
      return 'translate(' + node.x + ',' + node.y + ')';
    })
    .style('opacity', 1e-6)
    .remove();
}
298932
function cloneIfElseNodes(element, hasElse) {
      var children = childNodes(element),
          ifNodes = [],
          elseNodes = [],
          target = ifNodes;
        
      for (var i = 0, j = children.length; i < j; ++i) {
          if (hasElse && isElseNode(children[i])) {
              target = elseNodes;
              hasElse = false;
          } else {
              target.push(cleanNode(children[i].cloneNode(true)));
          }
      }
      
      return {
          ifNodes: ifNodes,
          elseNodes: elseNodes
      };
  }
453501
function (nodes, options) {
    /*
     * In collapse operation there is no fisheye view to be applied so there is no animation to be destroyed here. We can do this 
     * in a batch.
     */ 
    cy.startBatch();
    this.simpleCollapseGivenNodes(nodes, options);
    cy.endBatch();

    nodes.trigger("position"); // position not triggered by default when collapseNode is called
    this.endOperation(options.layoutBy);

    // Update the style
    cy.style().update();

    /*
     * return the nodes to undo the operation
     */
    return nodes;
  }
744712
function getBlockNodes(nodes) {
  // TODO(perf): just check if all items in `nodes` are siblings and if they are return the original
  //             collection, otherwise update the original collection.
  var node = nodes[0];
  var endNode = nodes[nodes.length - 1];
  var blockNodes = [node];

  do {
    node = node.nextSibling;
    if (!node) break;
    blockNodes.push(node);
  } while (node !== endNode);

  return jqLite(blockNodes);
}
982162
function(options) {
        var doc             = node.ownerDocument,
          nextSibling     = wysihtml5.dom.domNode(node).next({ignoreBlankTexts: true}),
          previousSibling = wysihtml5.dom.domNode(node).prev({ignoreBlankTexts: true});

        if (nextSibling && !_isLineBreakOrBlockElement(nextSibling)) {
          wysihtml5.dom.insert(doc.createElement("br")).after(node);
        }
        if (previousSibling && !_isLineBreakOrBlockElement(previousSibling)) {
          wysihtml5.dom.insert(doc.createElement("br")).before(node);
        }
      }
105347
function _onNodesAdded(nodes) {
        var i;
        for (i = 0; i < nodes.length; i++) {
            //check for Javascript files
            if (Utils.isExternalScript(nodes[i])) {
                _transport.send(JSON.stringify({
                    method: 'ScriptAdded',
                    src: nodes[i].src
                }));
            }
            //check for stylesheets
            if (Utils.isExternalStylesheet(nodes[i])) {
                CSS.checkForStylesheetLoaded(nodes[i].href);
            }
        }
    }
889985
function createNode (options, callback) {
  if (typeof options === 'function') {
    callback = options
    options = {}
  }

  options.path = options.path || '/tmp/ipfs' + Math.random()

  const node = new IPFS({
    repo: options.path
  })

  node.on('start', () => callback(null, node))
}
586279
function split(nodes) {
    var section = [];

    var sections = _.reduce(nodes, function(sections, el) {
        if(el.type === 'hr') {
            sections.push(section);
            section = [];
        } else {
            section.push(el);
        }

        return sections;
    }, [])
     // Add remaining nodes
    .concat([section])
    // Exclude empty sections
    .filter(_.negate(_.isEmpty));

    // Copy over links (kramed needs them)
    sections.links = nodes.links || {};

    return sections;
}
734274
function flattenNodes(nodes) {
	return nodes.reduce((acc, item) => {
		if (item.nodes) acc.push(...flattenNodes(item.nodes))
		else acc.push(item);
		return acc;
	}, []);
}
1339343
function renderNode(rootNode) {
    let createdPromises = [];

    var document = getDocument(rootNode);

    recurseTree(rootNode, (foundNode) => {
        if (foundNode.tagName) {
            let nodeType = foundNode.tagName.toLowerCase();
            let customElement = registeredElements[nodeType];
            if (customElement) {
                // TODO: Should probably clone node, not change prototype, for performance
                Object.setPrototypeOf(foundNode, customElement);
                if (customElement.createdCallback) {
                    createdPromises.push(new Promise((resolve) => {
                        resolve(customElement.createdCallback.call(foundNode, document));
                    }));
                }
            }
        }
    });

    return Promise.all(createdPromises).then(() => rootNode);
}
705871
function( options ){

			// if a node is passed
			if(options.node){
				this.rootNode = options.node;
			}


			// if a html string is passed
			if(options.html){
				//var domParser = new DOMParser();
                var domParser = this.getDOMParser();
       			this.rootNode = domParser.parseFromString( options.html, 'text/html' );
			}


			// find top level document from rootnode
			if(this.rootNode !== null){
				if(this.rootNode.nodeType === 9){
					this.document = this.rootNode;
					this.rootNode = modules.domUtils.querySelector(this.rootNode, 'html');
				}else{
					// if it's DOM node get parent DOM Document
					this.document = modules.domUtils.ownerDocument(this.rootNode);
				}
			}


			// use global document object
			if(!this.rootNode && document){
				this.rootNode = modules.domUtils.querySelector(document, 'html');
				this.document = document;
			}


			if(this.rootNode && this.document){
				return {document: this.document, rootNode: this.rootNode};
			}

			return {document: null, rootNode: null};
		}
885902
protected function renderNodes($nodes)
    {
        $lines = [];

        if (!empty($nodes)) {

            $nodesOptions = $this->nodesOptions;
            $tag = ArrayHelper::remove($nodesOptions, 'tag', 'ol');
            $lines[] =  Html::beginTag($tag, $nodesOptions);

            foreach ($nodes as $node) {
                if (isset($node['visible']) && !$node['visible']) {
                    continue;
                }
                $lines[] = $this->renderNode($node);
            }

            $lines[] =  Html::endTag($tag); 
        }

        return implode("\n", $lines);
    }