How to use the inferno-vnode-flags.VNodeFlags.Element 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
}
      } else {
        const renderOutput = type(props, context);

        if (isInvalid(renderOutput)) {
          this.addToQueue('', position);
        } else if (isString(renderOutput)) {
          this.addToQueue(escapeText(renderOutput), position);
        } else if (isNumber(renderOutput)) {
          this.addToQueue(renderOutput + '', position);
        } else {
          this.renderVNodeToQueue(renderOutput, context, position);
        }
      }
      // If an element
    } else if ((flags & VNodeFlags.Element) > 0) {
      let renderedString = `<${type}`;
      let html;
      const isVoidElement = voidElements.has(type);
      const className = vNode.className;

      if (isString(className)) {
        renderedString += ` class="${escapeText(className)}"`;
      } else if (isNumber(className)) {
        renderedString += ` class="${className}"`;
      }

      if (!isNull(props)) {
        for (const prop in props) {
          const value = props[prop];

          switch (prop) {
github infernojs / inferno / packages / inferno-router / src / utils.ts View on Github external
export function isValidElement(obj: any): boolean {
  const isValidObject = typeof obj === 'object' && !isNull(obj);

  if (!isValidObject) {
    return false;
  }

  return (obj.flags & (VNodeFlags.Component | VNodeFlags.Element)) > 0;
}
github infernojs / inferno / packages / inferno-server / src / renderToString.ts View on Github external
return renderVNodeToString(renderOutput, vNode, childContext);
    } else {
      const renderOutput = type(props, context);

      if (isInvalid(renderOutput)) {
        return '';
      }
      if (isString(renderOutput)) {
        return escapeText(renderOutput);
      }
      if (isNumber(renderOutput)) {
        return renderOutput + '';
      }
      return renderVNodeToString(renderOutput, vNode, context);
    }
  } else if ((flags & VNodeFlags.Element) !== 0) {
    let renderedString = `<${type}`;
    let html;

    const isVoidElement = voidElements.has(type);
    const className = vNode.className;

    if (isString(className)) {
      renderedString += ` class="${escapeText(className)}"`;
    } else if (isNumber(className)) {
      renderedString += ` class="${className}"`;
    }

    if (!isNull(props)) {
      for (const prop in props) {
        const value = props[prop];
github infernojs / inferno / packages / inferno-server / src / renderToString.stream.ts View on Github external
public renderNode(vNode, context) {
    const flags = vNode.flags;

    if ((flags & VNodeFlags.Component) > 0) {
      return this.renderComponent(vNode, context, flags & VNodeFlags.ComponentClass);
    }
    if ((flags & VNodeFlags.Element) > 0) {
      return this.renderElement(vNode, context);
    }

    return this.renderText(vNode);
  }
github infernojs / inferno / packages / inferno-compat / src / index.ts View on Github external
}
  if (vNode.flags & VNodeFlags.Component) {
    if (isString(vNode.type)) {
      vNode.flags = getFlagsForElementVnode(vNode.type as string);
      if (props) {
        normalizeProps(vNode);
      }
    }
  }

  const flags = vNode.flags;

  if (flags & VNodeFlags.FormElement) {
    normalizeFormProps(vNode.type, props);
  }
  if (flags & VNodeFlags.Element) {
    if (vNode.className) {
      props.className = vNode.className;
    }
    normalizeGenericProps(props);
  }

  if (oldCreateVNode) {
    oldCreateVNode(vNode);
  }
};
github infernojs / inferno / packages / inferno-hydrate / src / index.ts View on Github external
function hydrateVNode(vNode: VNode, parentDOM: Element, currentDom: Element, context: Object, isSVG: boolean, lifecycle: Function[]): Element | null {
  const flags = (vNode.flags |= VNodeFlags.InUse);

  if (flags & VNodeFlags.Component) {
    return hydrateComponent(vNode, parentDOM, currentDom, context, isSVG, (flags & VNodeFlags.ComponentClass) > 0, lifecycle);
  }
  if (flags & VNodeFlags.Element) {
    return hydrateElement(vNode, parentDOM, currentDom, context, isSVG, lifecycle);
  }
  if (flags & VNodeFlags.Text) {
    return hydrateText(vNode, parentDOM, currentDom);
  }
  if (flags & VNodeFlags.Void) {
    return (vNode.dom = currentDom);
  }
  if (flags & VNodeFlags.Fragment) {
    return hydrateFragment(vNode, parentDOM, currentDom, context, isSVG, lifecycle);
  }

  if (process.env.NODE_ENV !== 'production') {
    throwError(`hydrate() expects a valid VNode, instead it received an object with the type "${typeof vNode}".`);
  }
  throwError();