TemplateElement

@mvuijs/core / TemplateElement

TemplateElement<T, Params, Props> #

The internal representation of any element in a Component s template. Do not instantiate these yourself. Instead, use the h constant/namespace:

Example #

class MyComponent extends Component {
  render() {
    return [
      h.div('hi'),
      h.span('double hi'),
      h.custom('custom-web-component'),
      // ...
    ]
  }
}

Type parameters #

  • T extends HTMLElement
  • Params extends ParamSpec = {}
  • Props extends {

} = {}

Constructors #

constructor() #

Signature #

new TemplateElement<T, Params, Props>(creator: Function, childrenOrParams?: TemplateElementChildren<any> | TemplateElementParams<T, {}, {}>, children?: TemplateElementChildren<any>): TemplateElement<T, Params, Props>;

Type parameters #

  • T extends HTMLElement
  • Params extends ParamSpec = {}
  • Props extends {

} = {}

Parameters #

Name Type
creator () => T
childrenOrParams? TemplateElementChildren <any> | TemplateElementParams <T, {}, {}>
children? TemplateElementChildren <any>

Returns #

TemplateElement <T, Params, Props>

Defined in: packages/core/src/template-element.ts:55

Properties #

children #

TemplateElementChildren <any> = []

Defined in: packages/core/src/template-element.ts:53

creator #

Function

Type declaration #

Signature #
(): T;
Returns #

T

Defined in: packages/core/src/template-element.ts:56

params #

TemplateElementParams <T, Params, Props>

Defined in: packages/core/src/template-element.ts:52

Methods #

fromCustom() #

Signature #

Static fromCustom<T, Params>(creator: Function): TemplateElementCreator<T, Params, never>;

Type parameters #

  • T extends HTMLElement
  • Params extends ParamSpec = {}

Parameters #

Name Type
creator () => T

Returns #

TemplateElementCreator <T, Params, never>

Defined in: packages/core/src/template-element.ts:77

Signature #

Static fromCustom<T, Params>(creator: Function): TemplateElementCreator<T, Params, never>;

Type parameters #

  • T extends HTMLElement
  • Params extends ParamSpec = {}

Parameters #

Name Type
creator () => T

Returns #

TemplateElementCreator <T, Params, never>

Defined in: packages/core/src/template-element.ts:84

Signature #

Static fromCustom<T>(tagName: T): TemplateElementCreator<HTMLElementTagNameMap[T], {}, never>;

Type parameters #

  • T extends keyof HTMLElementTagNameMap

Parameters #

Name Type
tagName T

Returns #

TemplateElementCreator <HTMLElementTagNameMap[T], {}, never>

Defined in: packages/core/src/template-element.ts:91

Signature #

Static fromCustom<T, Params>(tagName: string): TemplateElementCreator<any, Params, never>;

Type parameters #

  • T extends HTMLElement = HTMLElement
  • Params extends ParamSpec = any

Parameters #

Name Type
tagName string

Returns #

TemplateElementCreator <any, Params, never>

Defined in: packages/core/src/template-element.ts:94