UNPKG

@cycle/dom

Version:

The standard DOM Driver for Cycle.js, based on Snabbdom

242 lines 4.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // tslint:disable:max-file-line-count var snabbdom_1 = require("snabbdom"); function isValidString(param) { return typeof param === 'string' && param.length > 0; } function isSelector(param) { return isValidString(param) && (param[0] === '.' || param[0] === '#'); } function createTagFunction(tagName) { return function hyperscript(a, b, c) { var hasA = typeof a !== 'undefined'; var hasB = typeof b !== 'undefined'; var hasC = typeof c !== 'undefined'; if (isSelector(a)) { if (hasB && hasC) { return snabbdom_1.h(tagName + a, b, c); } else if (hasB) { return snabbdom_1.h(tagName + a, b); } else { return snabbdom_1.h(tagName + a, {}); } } else if (hasC) { return snabbdom_1.h(tagName + a, b, c); } else if (hasB) { return snabbdom_1.h(tagName, a, b); } else if (hasA) { return snabbdom_1.h(tagName, a); } else { return snabbdom_1.h(tagName, {}); } }; } var SVG_TAG_NAMES = [ 'a', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform', 'circle', 'clipPath', 'colorProfile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotlight', 'feTile', 'feTurbulence', 'filter', 'font', 'fontFace', 'fontFaceFormat', 'fontFaceName', 'fontFaceSrc', 'fontFaceUri', 'foreignObject', 'g', 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missingGlyph', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'script', 'set', 'stop', 'style', 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern', ]; var svg = createTagFunction('svg'); SVG_TAG_NAMES.forEach(function (tag) { svg[tag] = createTagFunction(tag); }); var TAG_NAMES = [ 'a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'details', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'meta', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'p', 'param', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'u', 'ul', 'video', ]; var exported = { SVG_TAG_NAMES: SVG_TAG_NAMES, TAG_NAMES: TAG_NAMES, svg: svg, isSelector: isSelector, createTagFunction: createTagFunction, }; TAG_NAMES.forEach(function (n) { exported[n] = createTagFunction(n); }); exports.default = exported; //# sourceMappingURL=hyperscript-helpers.js.map