当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript inferno.createVNode函数代码示例

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


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

示例1: it

	it('Patch operation when nextChildren is NOT Invalid/Array/StringOrNumber/VNode', () => {
		const validNode = createVNode(
			VNodeFlags.HtmlElement,
			'span',
			null,
			createVNode(
				VNodeFlags.HtmlElement,
				'span',
				null,
				createTextVNode('a'),
				null,
				null,
				false
			),
			null,
			null,
			false
		);

		const invalidChildNode = createVNode(
			VNodeFlags.HtmlElement,
			'span',
			null,
			createVNode(0, 'span'),
			null,
			null,
			false
		);

		render(validNode, container);
		render(invalidChildNode, container);
	});
开发者ID:Keats,项目名称:inferno,代码行数:32,代码来源:patching.spec.ts

示例2: it

	it('Should create new object when dom exists', () => {
		const bar = createVNode(2, 'div', null, '123', null, null, true);
		const foo = createVNode(2, 'div', null, bar, null, null, true);

		render(foo, container);
		expect(container.innerHTML).to.eql('<div><div>123</div></div>');

		render(null, container);

		render(foo, container);
		expect(container.innerHTML).to.eql('<div><div>123</div></div>');
	});
开发者ID:Keats,项目名称:inferno,代码行数:12,代码来源:rendering.spec.ts

示例3: renderLink

function renderLink(classNm, children, otherProps) {
  return createVNode(
    VNodeFlags.HtmlElement,
    "a",
    classNm,
    children,
    otherProps
  );
}
开发者ID:russelgal,项目名称:inferno,代码行数:9,代码来源:Link.ts

示例4: hyperscript

/**
 * Creates virtual node
 * @param {string|VNode|Function} _tag Name for virtual node
 * @param {object=} _props Additional properties for virtual node
 * @param {string|number|VNode|Array<string|number|VNode>|null=} _children Optional children for virtual node
 * @returns {VNode} returns new virtual node
 */
export default function hyperscript(
  _tag: string | VNode | Function,
  _props?: any,
  _children?: InfernoChildren
): VNode {
  // If a child array or text node are passed as the second argument, shift them
  if (!_children && isChildren(_props)) {
    _children = _props;
    _props = {};
  }
  const isElement = isString(_tag);
  const { tag, props, key, ref, children, className } = extractProps(
    _props,
    isElement,
    _tag as VNode
  );

  if (isElement) {
    return createVNode(
      getFlagsForElementVnode(tag),
      tag,
      className,
      _children || children,
      props,
      key,
      ref
    );
  } else {
    if (children || _children) {
      (props as any).children = children || _children;
    }
    return createVNode(
      VNodeFlags.ComponentUnknown,
      tag,
      className,
      null,
      props,
      key,
      ref
    );
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:49,代码来源:index.ts

示例5: renderIntoDocument

export function renderIntoDocument(input): Wrapper {
  const wrappedInput = createVNode(
    VNodeFlags.ComponentClass,
    Wrapper,
    null,
    null,
    { children: input }
  );
  const parent = document.createElement("div");
  document.body.appendChild(parent);
  return render(wrappedInput, parent) as any;
}
开发者ID:russelgal,项目名称:inferno,代码行数:12,代码来源:index.ts

示例6: hyperscript

export default function hyperscript(_tag: string | VNode, _props?: any, _children?: InfernoChildren): VNode {
	// If a child array or text node are passed as the second argument, shift them
	if (!_children && isChildren(_props)) {
		_children = _props;
		_props = {};
	}
	const { tag, props, key, ref, children, events } = extractProps(_props, _tag);

	if (isString(tag)) {
		let flags = VNodeFlags.HtmlElement;

		switch (tag) {
			case 'svg':
				flags = VNodeFlags.SvgElement;
				break;
			case 'input':
				flags = VNodeFlags.InputElement;
				break;
			case 'textarea':
				flags = VNodeFlags.TextareaElement;
				break;
			case 'select':
				flags = VNodeFlags.SelectElement;
				break;
			default:
		}
		return createVNode(flags, tag, props, _children || children, events, key, ref);
	} else {
		const flags = isStatefulComponent(tag) ? VNodeFlags.ComponentClass : VNodeFlags.ComponentFunction;

		if (children) {
			(props as any).children = children;
		}
		return createVNode(flags, tag, props, null, null, key, ref);
	}
}
开发者ID:Keats,项目名称:inferno,代码行数:36,代码来源:hyperscript.ts

示例7: render

  public render(props): VNode | null {
    const hit = match(props.children, this.state.url);

    if (hit.redirect) {
      setTimeout(() => {
        this.router.replace(hit.redirect);
      }, 0);
      return null;
    }

    return createVNode(VNodeFlags.ComponentClass, RouterContext, null, null, {
      location: this.state.url,
      matched: hit.matched,
      router: this.router
    });
  }
开发者ID:russelgal,项目名称:inferno,代码行数:16,代码来源:Router.ts


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