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

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

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

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



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

示例1: patchStyle

// We are assuming here that we come from patchProp routine
// -nextAttrValue cannot be null or undefined
function patchStyle(lastAttrValue, nextAttrValue, dom) {
  const domStyle = dom.style;
  let style;
  let value;

  if (isString(nextAttrValue)) {
    domStyle.cssText = nextAttrValue;
    return;
  }

  if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) {
    for (style in nextAttrValue) {
      // do not add a hasOwnProperty check here, it affects performance
      value = nextAttrValue[style];
      if (value !== lastAttrValue[style]) {
        domStyle[style] =
          !isNumber(value) || isUnitlessNumber.has(style)
            ? value
            : value + "px";
      }
    }

    for (style in lastAttrValue) {
      if (isNullOrUndef(nextAttrValue[style])) {
        domStyle[style] = "";
      }
    }
  } else {
    for (style in nextAttrValue) {
      value = nextAttrValue[style];
      domStyle[style] =
        !isNumber(value) || isUnitlessNumber.has(style) ? value : value + "px";
    }
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:37,代码来源:patching.ts


示例2: renderAttributes

export function renderAttributes(props): string[] {
  const outputAttrs: string[] = [];
  const propsKeys = (props && Object.keys(props)) || [];

  for (let i = 0, len = propsKeys.length; i < len; i++) {
    const prop = propsKeys[i];

    if (
      prop !== "children" &&
      prop !== "dangerouslySetInnerHTML" &&
      prop !== "style"
    ) {
      const value = props[prop];

      if (isString(value)) {
        outputAttrs.push(prop + '="' + escapeText(value) + '"');
      } else if (isNumber(value)) {
        outputAttrs.push(prop + '="' + value + '"');
      } else if (isTrue(value)) {
        outputAttrs.push(prop);
      }
    }
  }

  return outputAttrs;
}
开发者ID:russelgal,项目名称:inferno,代码行数:26,代码来源:prop-renderers.ts


示例3: isVNode

export function isVNode(instance: any): instance is VNode {
  return (
    Boolean(instance) &&
    isObject(instance) &&
    isNumber((instance as any).flags) &&
    (instance as any).flags > 0
  );
}
开发者ID:russelgal,项目名称:inferno,代码行数:8,代码来源:index.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: renderStylesToString

export function renderStylesToString(styles: string | object): string {
  if (isString(styles)) {
    return styles;
  } else {
    let renderedString = "";
    for (const styleName in styles) {
      const value = styles[styleName];

      if (isString(value)) {
        renderedString += `${getCssPropertyName(styleName)}${value};`;
      } else if (isNumber(value)) {
        renderedString += `${getCssPropertyName(
          styleName
        )}${value}${internal_isUnitlessNumber.has(styleName) ? "" : "px"};`;
      }
    }
    return renderedString;
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:19,代码来源:prop-renderers.ts


示例6: renderVNodeToString

function renderVNodeToString(
  vNode,
  parent,
  context,
  firstChild
): string | undefined {
  const flags = vNode.flags;
  const type = vNode.type;
  const props = vNode.props || EMPTY_OBJ;
  const children = vNode.children;

  if ((flags & VNodeFlags.Component) > 0) {
    const isClass = flags & VNodeFlags.ComponentClass;

    if (isClass) {
      const instance = new type(props, context);
      instance._blockSetState = false;
      let childContext;
      if (isFunction(instance.getChildContext)) {
        childContext = instance.getChildContext();
      }

      if (isNullOrUndef(childContext)) {
        childContext = context;
      } else {
        childContext = combineFrom(context, childContext);
      }
      if (instance.props === EMPTY_OBJ) {
        instance.props = props;
      }
      instance.context = context;
      instance._unmounted = false;
      if (isFunction(instance.componentWillMount)) {
        instance._blockRender = true;
        instance.componentWillMount();
        if (instance._pendingSetState) {
          const state = instance.state;
          const pending = instance._pendingState;

          if (state === null) {
            instance.state = pending;
          } else {
            for (const key in pending) {
              state[key] = pending[key];
            }
          }
          instance._pendingSetState = false;
          instance._pendingState = null;
        }
        instance._blockRender = false;
      }
      const nextVNode = instance.render(props, instance.state, instance.context);
      // In case render returns invalid stuff
      if (isInvalid(nextVNode)) {
        return "<!--!-->";
      }
      return renderVNodeToString(nextVNode, vNode, childContext, true);
    } else {
      const nextVNode = type(props, context);

      if (isInvalid(nextVNode)) {
        return "<!--!-->";
      }
      return renderVNodeToString(nextVNode, vNode, context, true);
    }
  } 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];

        if (prop === "dangerouslySetInnerHTML") {
          html = value.__html;
        } else if (prop === "style") {
          renderedString += ` style="${renderStylesToString(props.style)}"`;
        } else if (prop === "children") {
          // Ignore children as prop.
        } else if (prop === "defaultValue") {
          // Use default values if normal values are not present
          if (!props.value) {
            renderedString += ` value="${isString(value)
              ? escapeText(value)
              : value}"`;
          }
        } else if (prop === "defaultChecked") {
          // Use default values if normal values are not present
          if (!props.checked) {
            renderedString += ` checked="${value}"`;
          }
        } else {
//.........这里部分代码省略.........
开发者ID:russelgal,项目名称:inferno,代码行数:101,代码来源:renderToString.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript inferno-shared.isObject函数代码示例发布时间:2022-05-25
下一篇:
TypeScript inferno-shared.isNullOrUndef函数代码示例发布时间: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