當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。