h9t.js
Shorthand HTMLElement constructor.
- Home: https://github.com/twhb/h9t.js
- npm: h9t
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 setsnewElement.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
Textthen appended - An
Array, which is iterated over and this algorithm run on each item - An Object, the
toNodemethod of which is invoked to obtain theNodeto append - A falsy value, which is ignored