• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript inferno-shared.isNull函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中inferno-shared.isNull函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isNull函数的具体用法?TypeScript isNull怎么用?TypeScript isNull使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了isNull函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: hydrateChildren

function hydrateChildren(
  children: InfernoChildren,
  parentDom: Element,
  lifecycle: LifecycleClass,
  context: Object,
  isSVG: boolean
): void {
  normalizeChildNodes(parentDom);
  let dom = parentDom.firstChild;

  if (isStringOrNumber(children)) {
    if (!isNull(dom) && dom.nodeType === 3) {
      if (dom.nodeValue !== children) {
        dom.nodeValue = children as string;
      }
    } else if (children === "") {
      parentDom.appendChild(document.createTextNode(""));
    } else {
      parentDom.textContent = children as string;
    }
    if (!isNull(dom)) {
      dom = (dom as Element).nextSibling;
    }
  } else if (isArray(children)) {
    for (
      let i = 0, len = (children as Array<string | number | VNode>).length;
      i < len;
      i++
    ) {
      const child = children[i];

      if (!isNull(child) && isObject(child)) {
        if (!isNull(dom)) {
          const nextSibling = dom.nextSibling;
          hydrate(child as VNode, dom as Element, lifecycle, context, isSVG);
          dom = nextSibling;
        } else {
          mount(child as VNode, parentDom, lifecycle, context, isSVG);
        }
      }
    }
  } else {
    // It's VNode
    if (!isNull(dom)) {
      hydrate(children as VNode, dom as Element, lifecycle, context, isSVG);
      dom = (dom as Element).nextSibling;
    } else {
      mount(children as VNode, parentDom, lifecycle, context, isSVG);
    }
  }

  // clear any other DOM nodes, there should be only a single entry for the root
  while (dom) {
    const nextSibling = dom.nextSibling;
    parentDom.removeChild(dom);
    dom = nextSibling;
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:58,代码来源:hydration.ts


示例2: poolComponent

export function poolComponent(vNode: VNode) {
  const hooks = vNode.ref as Refs;
  const nonRecycleHooks =
    hooks &&
    (hooks.onComponentWillMount ||
      hooks.onComponentWillUnmount ||
      hooks.onComponentDidMount ||
      hooks.onComponentWillUpdate ||
      hooks.onComponentDidUpdate);
  if (nonRecycleHooks) {
    return;
  }
  const type = vNode.type;
  const key = vNode.key;
  let pools: Pools | undefined = componentPools.get(type as Function);

  if (isUndefined(pools)) {
    pools = {
      keyed: new Map<string | number, VNode[]>(),
      nonKeyed: []
    };
    componentPools.set(type as Function, pools);
  }
  if (isNull(key)) {
    pools.nonKeyed.push(vNode);
  } else {
    let pool = pools.keyed.get(key);

    if (isUndefined(pool)) {
      pool = [];
      pools.keyed.set(key, pool);
    }
    pool.push(vNode);
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:35,代码来源:recycling.ts


示例3: _normalizeVNodes

function _normalizeVNodes(
  nodes: any[],
  result: VNode[],
  index: number,
  currentKey
) {
  for (const len = nodes.length; index < len; index++) {
    let n = nodes[index];
    const key = `${currentKey}.${index}`;

    if (!isInvalid(n)) {
      if (isArray(n)) {
        _normalizeVNodes(n, result, 0, key);
      } else {
        if (isStringOrNumber(n)) {
          n = createTextVNode(n, null);
        } else if ((isVNode(n) && n.dom) || (n.key && n.key[0] === ".")) {
          n = directClone(n);
        }
        if (isNull(n.key) || n.key[0] === ".") {
          n = applyKey(key, n as VNode);
        } else {
          n = applyKeyPrefix(currentKey, n as VNode);
        }

        result.push(n);
      }
    }
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:30,代码来源:normalization.ts


示例4: applyKeyIfMissing

function applyKeyIfMissing(key: string | number, vNode: VNode): VNode {
  if (isNumber(key)) {
    key = `.${key}`;
  }
  if (isNull(vNode.key) || vNode.key[0] === ".") {
    return applyKey(key as string, vNode);
  }
  return vNode;
}
开发者ID:russelgal,项目名称:inferno,代码行数:9,代码来源:normalization.ts


示例5: isValidElement

export default function isValidElement(obj: VNode): boolean {
  const isNotANullObject = isObject(obj) && isNull(obj) === false;
  if (isNotANullObject === false) {
    return false;
  }
  const flags = obj.flags;

  return (flags & (VNodeFlags.Component | VNodeFlags.Element)) > 0;
}
开发者ID:russelgal,项目名称:inferno,代码行数:9,代码来源:isValidElement.ts


示例6: mountVoid

export function mountVoid(vNode: VNode, parentDom: Element | null) {
  const dom = document.createTextNode("");

  vNode.dom = dom as any;
  if (!isNull(parentDom)) {
    appendChild(parentDom, dom);
  }
  return dom;
}
开发者ID:russelgal,项目名称:inferno,代码行数:9,代码来源:mounting.ts


示例7: updateTextContent

export function updateTextContent(dom, text: string | number) {
  const textNode = dom.firstChild;

  // Guard against external change on DOM node.
  if (isNull(textNode)) {
    setTextContent(dom, text);
  } else {
    textNode.nodeValue = text;
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:10,代码来源:utils.ts


示例8: mountText

export function mountText(vNode: VNode, parentDom: Element | null): any {
  const dom = document.createTextNode(vNode.children as string);

  vNode.dom = dom as any;
  if (!isNull(parentDom)) {
    appendChild(parentDom, dom);
  }

  return dom;
}
开发者ID:russelgal,项目名称:inferno,代码行数:10,代码来源:mounting.ts


示例9: renderToSnapshot

export function renderToSnapshot(input: VNode) {
  const wrapper = renderIntoDocument(input);
  const vnode = wrapper.props.children;

  if (!isNull(wrapper.props)) {
    const snapshot = vNodeToSnapshot(vnode.children as VNode);
    delete snapshot.props.children;
    return snapshot;
  }

  return undefined;
}
开发者ID:russelgal,项目名称:inferno,代码行数:12,代码来源:jest.ts


示例10: hydrateRoot

export function hydrateRoot(
  input,
  parentDom: Element | null,
  lifecycle: LifecycleClass
) {
  if (!isNull(parentDom)) {
    let dom = parentDom.firstChild as Element;

    if (!isNull(dom)) {
      hydrate(input, dom, lifecycle, EMPTY_OBJ, false);
      dom = parentDom.firstChild as Element;
      // clear any other DOM nodes, there should be only a single entry for the root
      while ((dom = dom.nextSibling as Element)) {
        parentDom.removeChild(dom);
      }
      return true;
    }
  }

  return false;
}
开发者ID:russelgal,项目名称:inferno,代码行数:21,代码来源:hydration.ts



注:本文中的inferno-shared.isNull函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript inferno-shared.isNullOrUndef函数代码示例发布时间:2022-05-25
下一篇:
TypeScript inferno-shared.isInvalid函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap