1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 | var h_1 = require("snabbdom/h");
|
5 | function isValidString(param) {
|
6 | return typeof param === 'string' && param.length > 0;
|
7 | }
|
8 | function isSelector(param) {
|
9 | return isValidString(param) && (param[0] === '.' || param[0] === '#');
|
10 | }
|
11 | function createTagFunction(tagName) {
|
12 | return function hyperscript(a, b, c) {
|
13 | var hasA = typeof a !== 'undefined';
|
14 | var hasB = typeof b !== 'undefined';
|
15 | var hasC = typeof c !== 'undefined';
|
16 | if (isSelector(a)) {
|
17 | if (hasB && hasC) {
|
18 | return h_1.h(tagName + a, b, c);
|
19 | }
|
20 | else if (hasB) {
|
21 | return h_1.h(tagName + a, b);
|
22 | }
|
23 | else {
|
24 | return h_1.h(tagName + a, {});
|
25 | }
|
26 | }
|
27 | else if (hasC) {
|
28 | return h_1.h(tagName + a, b, c);
|
29 | }
|
30 | else if (hasB) {
|
31 | return h_1.h(tagName, a, b);
|
32 | }
|
33 | else if (hasA) {
|
34 | return h_1.h(tagName, a);
|
35 | }
|
36 | else {
|
37 | return h_1.h(tagName, {});
|
38 | }
|
39 | };
|
40 | }
|
41 | var SVG_TAG_NAMES = [
|
42 | 'a',
|
43 | 'altGlyph',
|
44 | 'altGlyphDef',
|
45 | 'altGlyphItem',
|
46 | 'animate',
|
47 | 'animateColor',
|
48 | 'animateMotion',
|
49 | 'animateTransform',
|
50 | 'circle',
|
51 | 'clipPath',
|
52 | 'colorProfile',
|
53 | 'cursor',
|
54 | 'defs',
|
55 | 'desc',
|
56 | 'ellipse',
|
57 | 'feBlend',
|
58 | 'feColorMatrix',
|
59 | 'feComponentTransfer',
|
60 | 'feComposite',
|
61 | 'feConvolveMatrix',
|
62 | 'feDiffuseLighting',
|
63 | 'feDisplacementMap',
|
64 | 'feDistantLight',
|
65 | 'feFlood',
|
66 | 'feFuncA',
|
67 | 'feFuncB',
|
68 | 'feFuncG',
|
69 | 'feFuncR',
|
70 | 'feGaussianBlur',
|
71 | 'feImage',
|
72 | 'feMerge',
|
73 | 'feMergeNode',
|
74 | 'feMorphology',
|
75 | 'feOffset',
|
76 | 'fePointLight',
|
77 | 'feSpecularLighting',
|
78 | 'feSpotlight',
|
79 | 'feTile',
|
80 | 'feTurbulence',
|
81 | 'filter',
|
82 | 'font',
|
83 | 'fontFace',
|
84 | 'fontFaceFormat',
|
85 | 'fontFaceName',
|
86 | 'fontFaceSrc',
|
87 | 'fontFaceUri',
|
88 | 'foreignObject',
|
89 | 'g',
|
90 | 'glyph',
|
91 | 'glyphRef',
|
92 | 'hkern',
|
93 | 'image',
|
94 | 'line',
|
95 | 'linearGradient',
|
96 | 'marker',
|
97 | 'mask',
|
98 | 'metadata',
|
99 | 'missingGlyph',
|
100 | 'mpath',
|
101 | 'path',
|
102 | 'pattern',
|
103 | 'polygon',
|
104 | 'polyline',
|
105 | 'radialGradient',
|
106 | 'rect',
|
107 | 'script',
|
108 | 'set',
|
109 | 'stop',
|
110 | 'style',
|
111 | 'switch',
|
112 | 'symbol',
|
113 | 'text',
|
114 | 'textPath',
|
115 | 'title',
|
116 | 'tref',
|
117 | 'tspan',
|
118 | 'use',
|
119 | 'view',
|
120 | 'vkern',
|
121 | ];
|
122 | var svg = createTagFunction('svg');
|
123 | SVG_TAG_NAMES.forEach(function (tag) {
|
124 | svg[tag] = createTagFunction(tag);
|
125 | });
|
126 | var TAG_NAMES = [
|
127 | 'a',
|
128 | 'abbr',
|
129 | 'address',
|
130 | 'area',
|
131 | 'article',
|
132 | 'aside',
|
133 | 'audio',
|
134 | 'b',
|
135 | 'base',
|
136 | 'bdi',
|
137 | 'bdo',
|
138 | 'blockquote',
|
139 | 'body',
|
140 | 'br',
|
141 | 'button',
|
142 | 'canvas',
|
143 | 'caption',
|
144 | 'cite',
|
145 | 'code',
|
146 | 'col',
|
147 | 'colgroup',
|
148 | 'dd',
|
149 | 'del',
|
150 | 'details',
|
151 | 'dfn',
|
152 | 'dir',
|
153 | 'div',
|
154 | 'dl',
|
155 | 'dt',
|
156 | 'em',
|
157 | 'embed',
|
158 | 'fieldset',
|
159 | 'figcaption',
|
160 | 'figure',
|
161 | 'footer',
|
162 | 'form',
|
163 | 'h1',
|
164 | 'h2',
|
165 | 'h3',
|
166 | 'h4',
|
167 | 'h5',
|
168 | 'h6',
|
169 | 'head',
|
170 | 'header',
|
171 | 'hgroup',
|
172 | 'hr',
|
173 | 'html',
|
174 | 'i',
|
175 | 'iframe',
|
176 | 'img',
|
177 | 'input',
|
178 | 'ins',
|
179 | 'kbd',
|
180 | 'keygen',
|
181 | 'label',
|
182 | 'legend',
|
183 | 'li',
|
184 | 'link',
|
185 | 'main',
|
186 | 'map',
|
187 | 'mark',
|
188 | 'menu',
|
189 | 'meta',
|
190 | 'nav',
|
191 | 'noscript',
|
192 | 'object',
|
193 | 'ol',
|
194 | 'optgroup',
|
195 | 'option',
|
196 | 'p',
|
197 | 'param',
|
198 | 'pre',
|
199 | 'progress',
|
200 | 'q',
|
201 | 'rp',
|
202 | 'rt',
|
203 | 'ruby',
|
204 | 's',
|
205 | 'samp',
|
206 | 'script',
|
207 | 'section',
|
208 | 'select',
|
209 | 'small',
|
210 | 'source',
|
211 | 'span',
|
212 | 'strong',
|
213 | 'style',
|
214 | 'sub',
|
215 | 'summary',
|
216 | 'sup',
|
217 | 'table',
|
218 | 'tbody',
|
219 | 'td',
|
220 | 'textarea',
|
221 | 'tfoot',
|
222 | 'th',
|
223 | 'thead',
|
224 | 'time',
|
225 | 'title',
|
226 | 'tr',
|
227 | 'u',
|
228 | 'ul',
|
229 | 'video',
|
230 | ];
|
231 | var exported = {
|
232 | SVG_TAG_NAMES: SVG_TAG_NAMES,
|
233 | TAG_NAMES: TAG_NAMES,
|
234 | svg: svg,
|
235 | isSelector: isSelector,
|
236 | createTagFunction: createTagFunction,
|
237 | };
|
238 | TAG_NAMES.forEach(function (n) {
|
239 | exported[n] = createTagFunction(n);
|
240 | });
|
241 | exports.default = exported;
|
242 |
|
\ | No newline at end of file |