1.0.2 • Published 7 years ago

h9t v1.0.2

Weekly downloads
14
License
-
Repository
-
Last release
7 years ago

h9t.js

Shorthand HTMLElement constructor.

Example

h('div', 'example',
  h('h1', null, 'Example'),
  'h9t.js is exemplary!'
);

API

h(tagName, props, ...children)

Creates and returns a new HTMLElement.

tagName: A string, the tag name of the new HMTLElement. Passed to document.createElement.

props: Properties to set on the new HTMLElement. One of:

  • An object. Each key-value pair is copied onto the new HTMLElement, except style, which sets newElement.style.cssText.
  • A string. Sets the new HTMLElement's .className
  • A falsy value, which is ignored.

children: Children to append to the new HTMLElement. One of:

  • A Node
  • A string, which is wrapped in a Text then appended
  • An Array, which is iterated over and this algorithm run on each item
  • An Object, the toNode method of which is invoked to obtain the Node to append
  • A falsy value, which is ignored