UNPKG

@soil/dom

Version:

Declaratively create type-safe HTML and SVG elements.

149 lines 3.85 kB
import { addChildren } from '../addChildren'; import { assignProps } from '../../../shared/functions/assignProps'; /** * Factory function for HTML elements. */ function html(tag) { return function (props, children) { var elem = document.createElement(tag); if (props !== undefined) { assignProps(elem, props); } if (children !== undefined) { addChildren(elem, children); } return elem; }; } /** * Helpers to facilitate the concise creation of any HTML element. * * NOTE The following functions silently depend on the `document` variable * being globally available. Therefore, unit tests of components that use them * must be run inside a browser, or must expose `document` globally, e.g. * through PhantomJS or jsdom. * * TODO Missing: <rb>, <rtc>. */ export var h = { a: html('a'), abbr: html('abbr'), address: html('address'), applet: html('applet'), area: html('area'), article: html('article'), aside: html('aside'), audio: html('audio'), b: html('b'), base: html('base'), basefont: html('basefont'), bdi: html('bdi'), bdo: html('bdo'), blockquote: html('blockquote'), body: html('body'), br: html('br'), button: html('button'), canvas: html('canvas'), caption: html('caption'), cite: html('cite'), code: html('code'), col: html('col'), colgroup: html('colgroup'), data: html('data'), datalist: html('datalist'), dd: html('dd'), del: html('del'), details: html('details'), dfn: html('dfn'), dialog: html('dialog'), dir: html('dir'), div: html('div'), dl: html('dl'), dt: html('dt'), em: html('em'), embed: html('embed'), fieldset: html('fieldset'), figcaption: html('figcaption'), figure: html('figure'), font: html('font'), footer: html('footer'), form: html('form'), frame: html('frame'), frameset: html('frameset'), h1: html('h1'), h2: html('h2'), h3: html('h3'), h4: html('h4'), h5: html('h5'), h6: html('h6'), head: html('head'), header: html('header'), hgroup: html('hgroup'), hr: html('hr'), html: html('html'), i: html('i'), iframe: html('iframe'), img: html('img'), input: html('input'), ins: html('ins'), kbd: html('kbd'), label: html('label'), legend: html('legend'), li: html('li'), link: html('link'), main: html('main'), map: html('map'), mark: html('mark'), marquee: html('marquee'), menu: html('menu'), meta: html('meta'), meter: html('meter'), nav: html('nav'), noscript: html('noscript'), object: html('object'), ol: html('ol'), optgroup: html('optgroup'), option: html('option'), output: html('output'), p: html('p'), param: html('param'), picture: html('picture'), pre: html('pre'), progress: html('progress'), q: html('q'), rp: html('rp'), rt: html('rt'), ruby: html('ruby'), s: html('s'), samp: html('samp'), script: html('script'), section: html('section'), select: html('select'), slot: html('slot'), small: html('small'), source: html('source'), span: html('span'), strong: html('strong'), style: html('style'), sub: html('sub'), summary: html('summary'), sup: html('sup'), table: html('table'), tbody: html('tbody'), td: html('td'), template: html('template'), textarea: html('textarea'), tfoot: html('tfoot'), th: html('th'), thead: html('thead'), time: html('time'), title: html('title'), tr: html('tr'), track: html('track'), u: html('u'), ul: html('ul'), var: html('var'), video: html('video'), wbr: html('wbr'), }; //# sourceMappingURL=h.js.map