How to use the inferno-vnode-flags.ChildFlags.HasVNodeChildren 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-server / src / renderToString.queuestream.ts View on Github external
}
      renderedString += `>`;

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

      // Voided element, push directly to queue
      if (isVoidElement) {
        this.addToQueue(renderedString, position);
        // Regular element with content
      } else {
        // Element has children, build them in
        const childFlags = vNode.childFlags;

        if (childFlags === ChildFlags.HasVNodeChildren) {
          this.addToQueue(renderedString, position);
          this.renderVNodeToQueue(children, context, position);
          this.addToQueue('', position);
          return;
        } else if (childFlags === ChildFlags.HasTextChildren) {
          this.addToQueue(renderedString, position);
          this.addToQueue(children === '' ? ' ' : escapeText(children + ''), position);
          this.addToQueue('', position);
          return;
        } else if (childFlags & ChildFlags.MultipleChildren) {
          this.addToQueue(renderedString, position);
          for (let i = 0, len = children.length; i < len; ++i) {
            this.renderVNodeToQueue(children[i], context, position);
          }
          this.addToQueue('', position);
          return;
github infernojs / inferno / packages / inferno-server / src / renderToString.ts View on Github external
break;
        }
      }
      if (type === 'option' && typeof props.value !== 'undefined' && props.value === parent.props.value) {
        // Parent value sets children value
        renderedString += ` selected`;
      }
    }
    if (isVoidElement) {
      renderedString += `>`;
    } else {
      renderedString += `>`;
      const childFlags = vNode.childFlags;

      if (childFlags === ChildFlags.HasVNodeChildren) {
        renderedString += renderVNodeToString(children, vNode, context);
      } else if (childFlags & ChildFlags.MultipleChildren) {
        for (let i = 0, len = children.length; i < len; ++i) {
          renderedString += renderVNodeToString(children[i], vNode, context);
        }
      } else if (childFlags === ChildFlags.HasTextChildren) {
        renderedString += children === '' ? ' ' : escapeText(children);
      } else if (html) {
        renderedString += html;
      }
      if (!isVoidElement) {
        renderedString += ``;
      }
    }

    if (String(type).match(/[\s\n\/='"\0<>]/)) {
github infernojs / inferno / packages / inferno-extras / src / isDOMinsideVDOM.ts View on Github external
children = _vNode.children;

    if (flags & VNodeFlags.ComponentClass) {
      stack.push(children.$LI);
    } else if (flags & VNodeFlags.ComponentFunction) {
      stack.push(children);
    } else {
      flags = _vNode.childFlags;

      if (flags & ChildFlags.MultipleChildren) {
        let i = children.length;

        while (i--) {
          stack.push(children[i]);
        }
      } else if (flags & ChildFlags.HasVNodeChildren) {
        stack.push(children);
      }
    }
  }

  return false;
}
github infernojs / inferno / packages / inferno-server / src / renderToString.stream.ts View on Github external
public renderChildren(children: VNode[] | VNode | string, context: any, childFlags: ChildFlags) {
    if (childFlags === ChildFlags.HasVNodeChildren) {
      return this.renderNode(children, context);
    }
    if (childFlags === ChildFlags.HasTextChildren) {
      return this.push(children === '' ? ' ' : escapeText(children + ''));
    }
    if (childFlags & ChildFlags.MultipleChildren) {
      return (children as VNode[]).reduce((p, child) => {
        return p.then(() => {
          return Promise.resolve(this.renderNode(child, context)).then(() => !!(child.flags & VNodeFlags.Text));
        });
      }, Promise.resolve(false));
    }
  }
github infernojs / inferno / packages / inferno-hydrate / src / index.ts View on Github external
function hydrateChildren(parentVNode: VNode, parentNode, currentNode, context, isSVG, lifecycle: Function[]) {
  const childFlags = parentVNode.childFlags;
  const children = parentVNode.children;
  const props = parentVNode.props;
  const flags = parentVNode.flags;

  if (childFlags !== ChildFlags.HasInvalidChildren) {
    if (childFlags === ChildFlags.HasVNodeChildren) {
      if (isNull(currentNode)) {
        _M(children as VNode, parentNode, context, isSVG, null, lifecycle);
      } else {
        currentNode = hydrateVNode(children as VNode, parentNode, currentNode as Element, context, isSVG, lifecycle);
        currentNode = currentNode ? currentNode.nextSibling : null;
      }
    } else if (childFlags === ChildFlags.HasTextChildren) {
      if (isNull(currentNode)) {
        parentNode.appendChild(document.createTextNode(children as string));
      } else if (parentNode.childNodes.length !== 1 || currentNode.nodeType !== 3) {
        parentNode.textContent = children as string;
      } else {
        if (currentNode.nodeValue !== children) {
          currentNode.nodeValue = children as string;
        }
      }