Template helper which handles HTML; return a document fragment. Example: ``` document.body.appendChild(HTML`<span>${foo}</span><span>${bar}</span>`); ``` /* NEEDS WORK
196917
function HTML(strings, ...values) {
  var dummy = document.createElement('div');
  var fragment = document.createDocumentFragment();
  dummy.innerHTML = compose(strings, ...values);
  forEach.call(dummy.childNodes, appendChild, fragment);
  return fragment;
}
1339180
def create_element(cls, type_=None, props=None, *children):
        
        # Create an empty document fragment.
        if not type_:
            return cls.dom.create_tag('fragment')

        if props is None:
            props = {}

        # If the first element of children is a list, we use it as the list.
        if len(children) and isinstance(children[0], (list, tuple)):
            children = children[0]

        # The children prop is the first child if there is only one.
        props['children'] = children[0] if len(children) == 1 else children

        if callable(type_):
            # Function component, via def or lambda.
            elt = type_(props)
        else:
            # Raw tag, as a string.
            attributes = {}

            # Never render those attributes on a raw tag.
            props.pop('children', None)
            props.pop('block', None)
            props.pop('blocks', None)
            props.pop('entity', None)
            props.pop('inline_style_range', None)

            # Convert style object to style string, like the DOM would do.
            if 'style' in props and isinstance(props['style'], dict):
                rules = ['{0}: {1};'.format(DOM.camel_to_dash(s), props['style'][s]) for s in props['style'].keys()]
                props['style'] = ''.join(sorted(rules))

            # Convert props to HTML attributes.
            for key in props:
                if props[key] is False:
                    props[key] = 'false'

                if props[key] is True:
                    props[key] = 'true'

                if props[key] is not None:
                    attributes[key] = unicode(props[key])

            elt = cls.dom.create_tag(type_, attributes)

            # Append the children inside the element.
            for child in children:
                if child not in (None, ''):
                    cls.append_child(elt, child)

        # If elt is "empty", create a fragment anyway to add children.
        if elt in (None, ''):
            elt = cls.dom.create_tag('fragment')

        return elt
861852
function getInnerHtmlFromElement(page, ph, selector, callback) {
    function getInnerHtml(selector) {
        return document.querySelector(selector).innerHTML;
    }

    page.evaluate(getInnerHtml, function (result) {
        if (result) {
            callback(null, page, ph, result);
        } else {
            var errorString = 'Error finding innerHTML';
            callback(errorString, page, ph, null);
        }
    }, selector);
}
216161
function( data, context, scripts ) {
		var parsed;
		if ( !data || typeof data !== "string" ) {
			return null;
		}
		if ( typeof context === "boolean" ) {
			scripts = context;
			context = 0;
		}
		context = context || document;

		// Single tag
		if ( (parsed = rsingleTag.exec( data )) ) {
			return [ context.createElement( parsed[1] ) ];
		}

		parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] );
		return jQuery.merge( [],
			(parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes );
	}
937994
function createElement(tag, attribs, styles, parent, nopad) {
	var el = doc.createElement(tag);
	if (attribs) {
		extend(el, attribs);
	}
	if (nopad) {
		css(el, {padding: 0, border: NONE, margin: 0});
	}
	if (styles) {
		css(el, styles);
	}
	if (parent) {
		parent.appendChild(el);
	}
	return el;
}
224218
def process_markdown_inside_elements(doc)
      # find span elements or elements with 'markdown' attribute
      elts = @fragment.css("[markdown]")

      d = @fragment.children.first
      if d && HTML_INLINE_ELEMS.include?(d.name)
        elts << d unless d.attribute('markdown')
        elts += span_descendents(d)
      end

      elts.each do |e|
        how = e['markdown']
        e.remove_attribute('markdown')

        next if "0" == how # user requests no markdown parsing inside
        parse_blocks = (how == 'block') || BLOCK_TAGS.include?(e.name)

        # Select all text children of e
        e.xpath("./text()").each do |original_text|
          s = MaRuKu::Out::HTML.escapeHTML(original_text.text)
          unless s.strip.empty?
            parsed = parse_blocks ? doc.parse_text_as_markdown(s) : doc.parse_span(s)

            # restore leading and trailing spaces
            padding = /\A(\s*).*?(\s*)\z/.match(s)
            parsed = [padding[1]] + parsed + [padding[2]] if padding

            el = doc.md_el(:dummy, parsed)

            # Nokogiri collapses consecutive Text nodes, so replace it by a dummy element
            guard = Nokogiri::XML::Element.new('guard', @fragment)
            original_text.replace(guard)
            el.children_to_html.each do |x|
              guard.before(x.to_s)
            end
            guard.remove
          end
        end
      end
    end
430557
function createBranchedHTML(service, branchStatements, targetNode) {
    let template = service.template
    const stripedRanges = []

    /**
     * Strip template  of range.
     * @param  {number} start The start index of range.
     * @param  {number} end The end index of range.
     * @returns {void}
     */
    function strip(start, end) {
        const before = template.slice(0, start)
        const target = template.slice(start, end)
        const after = template.slice(end)
        template = before + target.replace(/\S/gu, " ") + after
        stripedRanges.push([start, end])
    }

    const visitor = {
        IfStatement(node) {
            if (
                node.alternate.range[0] <= targetNode.range[0] &&
                targetNode.range[0] < node.alternate.range[1]
            ) {
                strip(node.consequent.range[0], node.consequent.range[1])
            } else {
                strip(node.alternate.range[0], node.alternate.range[1])
            }
        },
        SwitchStatement(node) {
            let nodeCaseIndex = node.cases.findIndex((cur, index) => {
                const next = node.cases[index + 1]
                const endIndex = next ? next.range[0] : node.range[1]
                return (
                    cur.range[0] <= targetNode.range[0] &&
                    targetNode.range[0] < endIndex
                )
            })
            if (nodeCaseIndex < 0) {
                nodeCaseIndex = 0
            }
            node.cases.forEach((cur, index) => {
                if (index === nodeCaseIndex) {
                    return
                }
                const next = node.cases[index + 1]
                const endIndex = next ? next.range[0] : node.range[1]
                strip(cur.range[0], endIndex)
            })
        },
    }
    for (const node of branchStatements) {
        visitor[node.type](node)
    }

    return new BranchedHTML(
        template,
        service.parseHtml(template),
        stripedRanges
    )
}
271453
function getDocumentFragmentFromString(html) {
  // return document.createRange().createContextualFragment(html); // FU safari
  var range = document.createRange();
  range.selectNode(document.body);// safari
  return range.createContextualFragment(html);
}
1280557
def html(dom: str):
    
    r = _get_report()
    r.append_body(render.html(dom))
    r.stdout_interceptor.write_source('[ADDED] HTML\n')
779911
function fragment(html) {
  var args = arguments;
  var div = document.createElement('div');
  var i = 1;

  div.innerHTML = html.replace(/%([se])/g, function(_, type) {
    switch (type) {
      case 's':
        return String(args[i++]);
      case 'e':
        return escape(args[i++]);
      // no default
    }
  });

  return div.firstChild;
}
473178
function compile(fragments, template) {
  var walker = document.createTreeWalker(template, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT);
  var bindings = [], currentNode, parentNode, previousNode;

  // Reset first node to ensure it isn't a fragment
  walker.nextNode();
  walker.previousNode();

  // find bindings for each node
  do {
    currentNode = walker.currentNode;
    parentNode = currentNode.parentNode;
    bindings.push.apply(bindings, getBindingsForNode(fragments, currentNode, template));

    if (currentNode.parentNode !== parentNode) {
      // currentNode was removed and made a template
      walker.currentNode = previousNode || walker.root;
    } else {
      previousNode = currentNode;
    }
  } while (walker.nextNode());

  return bindings;
}
846566
function createElement(nodeName) {
  var elem = document.createElement(nodeName);
  elem.className = [].join.call(arguments, ' ');
  return elem;
}
1261637
function renderHtml(fragment, opts) {
    var html = (!fragment || !u.trim(fragment._txt)) ?
      '&nbsp;' : // show space for empty/missing to allow selection/editing
      renderMarkdown(fragment._txt, opts);
    // use opts.noWrap to avoid breaking CSS nested selectors like li > ul in menus
    if (opts && opts.noWrap) return html;
    var href = (fragment && esc(fragment._href)) || '';
    return '<div data-render-html="' + href + '">' + html + '</div>';
  }
99893
public static Document parseBodyFragment(String bodyHtml, String baseUri) {
        return Parser.parseBodyFragment(bodyHtml, baseUri);
    }
1051872
function(markup) {

        if (!markup) return undefined;

        var fragment = markup.fragment;
        if (!(markup.fragment instanceof DocumentFragment) || !markup.fragment.hasChildNodes()) throw new Error('dia.LinkView: invalid label markup.');

        var vNode;
        var childNodes = fragment.childNodes;

        if ((childNodes.length > 1) || childNodes[0].nodeName.toUpperCase() !== 'G') {
            // default markup fragment is not wrapped in <g />
            // add a <g /> container
            vNode = V('g').append(fragment);
        } else {
            vNode = V(childNodes[0]);
        }

        vNode.addClass('label');

        return { node: vNode.node, selectors: markup.selectors };
    }
107692
function createElement(tagName) {
  return function (...args) {
    const element  = document.createElement(tagName);
    const attrs    = isObject(args[0]) ? args[0] : {};
    const children = args.length === 2 ? args[1] : args[0];

    Object
      .keys(attrs)
      .forEach(name => element.setAttribute(name, attrs[name]));

    if (Array.isArray(children)) {
      children.forEach(node => append(element, node));
    }

    if (isString(children) && !isVoidElement(tagName.toLowerCase())) {
      append(element, children);
    }

    return element;
  };
}
806738
function listToFragment(list) {
  var fragment = document.createDocumentFragment();
  for (var i = 0, l = list.length; i < l; i++) {
    // Use toFragment since this may be an array of text, a jQuery object of `<template>`s, etc.
    fragment.appendChild(toFragment(list[i]));
    if (l === list.length + 1) {
      // adjust for NodeLists which are live, they shrink as we pull nodes out of the DOM
      i--;
      l--;
    }
  }
  return fragment;
}