How to use the inferno-vnode-flags.VNodeFlags.Fragment function in inferno-vnode-flags

To help you get started, we’ve selected a few inferno-vnode-flags examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github infernojs / inferno / packages / inferno-hydrate / src / index.ts View on Github external
for (let i = 0, len = (children as VNode[]).length; i < len; ++i) {
        const child = (children as VNode[])[i];

        if (isNull(currentNode) || (prevVNodeIsTextNode && (child.flags & VNodeFlags.Text) > 0)) {
          _M(child as VNode, parentNode, context, isSVG, currentNode, lifecycle);
        } else {
          currentNode = hydrateVNode(child as VNode, parentNode, currentNode as Element, context, isSVG, lifecycle);
          currentNode = currentNode ? currentNode.nextSibling : null;
        }

        prevVNodeIsTextNode = (child.flags & VNodeFlags.Text) > 0;
      }
    }

    // clear any other DOM nodes, there should be only a single entry for the root
    if ((flags & VNodeFlags.Fragment) === 0) {
      let nextSibling: Node | null = null;

      while (currentNode) {
        nextSibling = currentNode.nextSibling;
        parentNode.removeChild(currentNode);
        currentNode = nextSibling;
      }
    }
  } else if (!isNull(parentNode.firstChild) && !isSamePropsInnerHTML(parentNode, props)) {
    parentNode.textContent = ''; // dom has content, but VNode has no children remove everything from DOM
    if (flags & VNodeFlags.FormElement) {
      // If element is form element, we need to clear defaultValue also
      (parentNode as any).defaultValue = '';
    }
  }
}
github infernojs / inferno / packages / inferno-clone-vnode / src / index.ts View on Github external
while (childLen-- > 0) {
      children[childLen] = arguments[childLen + 2];
    }
  }

  props.children = children;

  if (flags & VNodeFlags.Component) {
    return createComponentVNode(flags, vNodeToClone.type, !vNodeToClone.props && !props ? EMPTY_OBJ : combineFrom(vNodeToClone.props, props), key, ref);
  }

  if (flags & VNodeFlags.Text) {
    return createTextVNode(children);
  }

  if (flags & VNodeFlags.Fragment) {
    return createFragment(childLen === 1 ? [children] : children, ChildFlags.UnknownChildren, key);
  }

  return normalizeProps(
    createVNode(flags, vNodeToClone.type, className, null, ChildFlags.HasInvalidChildren, combineFrom(vNodeToClone.props, props), key, ref)
  );
}
github infernojs / inferno / packages / inferno-server / src / renderToString.ts View on Github external
} else if (html) {
        renderedString += html;
      }
      if (!isVoidElement) {
        renderedString += ``;
      }
    }

    if (String(type).match(/[\s\n\/='"\0<>]/)) {
      throw renderedString;
    }

    return renderedString;
  } else if ((flags & VNodeFlags.Text) !== 0) {
    return children === '' ? ' ' : escapeText(children);
  } else if ((flags & VNodeFlags.Fragment) !== 0) {
    const childFlags = vNode.childFlags;

    if (childFlags === ChildFlags.HasVNodeChildren) {
      return '';
    } else if (childFlags & ChildFlags.MultipleChildren) {
      let renderedString = '';

      for (let i = 0, len = children.length; i < len; ++i) {
        renderedString += renderVNodeToString(children[i], vNode, context);
      }

      return renderedString;
    }
  } else {
    if (process.env.NODE_ENV !== 'production') {
      if (typeof vNode === 'object') {