@srfnstack/fntags 0.3.7 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/fnelements.mjs +87 -50
- package/src/fntags.mjs +35 -13
- package/src/svgelements.mjs +294 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@srfnstack/fntags",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"author": "Robert Kempton <r@snow87.com>",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/srfnstack/fntags",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"state-management"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"cypress": "
|
|
33
|
+
"cypress": "10.3.0",
|
|
34
34
|
"pre-commit": "^1.2.2",
|
|
35
35
|
"standard": "^16.0.4"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
|
-
"test": "npm run lint && cypress run --spec test/** --headless -b chrome",
|
|
38
|
+
"test": "cp src/* docs/lib/ && npm run lint && cypress run --spec test/** --headless -b chrome",
|
|
39
39
|
"cypress": "cypress run --spec test/** -b chrome",
|
|
40
40
|
"lint": "standard --env browser src && standard --env browser --env jest --global Prism --global cy test docs",
|
|
41
41
|
"lint:fix": "standard --env browser --fix src && standard --env browser --env jest --global Prism --global cy --fix test docs"
|
package/src/fnelements.mjs
CHANGED
|
@@ -6,17 +6,17 @@ import { h, styled } from './fntags.mjs'
|
|
|
6
6
|
export const a = (...children) => h('a', ...children)
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @type {function(...[*]=):
|
|
9
|
+
* @type {function(...[*]=): HTMLElement}
|
|
10
10
|
*/
|
|
11
11
|
export const abbr = (...children) => h('abbr', ...children)
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* @type {function(...[*]=):
|
|
14
|
+
* @type {function(...[*]=): HTMLElement}
|
|
15
15
|
*/
|
|
16
16
|
export const acronym = (...children) => h('acronym', ...children)
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @type {function(...[*]=):
|
|
19
|
+
* @type {function(...[*]=): HTMLElement}
|
|
20
20
|
*/
|
|
21
21
|
export const address = (...children) => h('address', ...children)
|
|
22
22
|
|
|
@@ -26,12 +26,12 @@ export const address = (...children) => h('address', ...children)
|
|
|
26
26
|
export const area = (...children) => h('area', ...children)
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* @type {function(...[*]=):
|
|
29
|
+
* @type {function(...[*]=): HTMLElement}
|
|
30
30
|
*/
|
|
31
31
|
export const article = (...children) => h('article', ...children)
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* @type {function(...[*]=):
|
|
34
|
+
* @type {function(...[*]=): HTMLElement}
|
|
35
35
|
*/
|
|
36
36
|
export const aside = (...children) => h('aside', ...children)
|
|
37
37
|
|
|
@@ -41,7 +41,7 @@ export const aside = (...children) => h('aside', ...children)
|
|
|
41
41
|
export const audio = (...children) => h('audio', ...children)
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* @type {function(...[*]=):
|
|
44
|
+
* @type {function(...[*]=): HTMLElement}
|
|
45
45
|
*/
|
|
46
46
|
export const b = (...children) => h('b', ...children)
|
|
47
47
|
|
|
@@ -51,17 +51,17 @@ export const b = (...children) => h('b', ...children)
|
|
|
51
51
|
export const base = (...children) => h('base', ...children)
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* @type {function(...[*]=):
|
|
54
|
+
* @type {function(...[*]=): HTMLElement}
|
|
55
55
|
*/
|
|
56
56
|
export const bdi = (...children) => h('bdi', ...children)
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* @type {function(...[*]=):
|
|
59
|
+
* @type {function(...[*]=): HTMLElement}
|
|
60
60
|
*/
|
|
61
61
|
export const bdo = (...children) => h('bdo', ...children)
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* @type {function(...[*]=):
|
|
64
|
+
* @type {function(...[*]=): HTMLElement}
|
|
65
65
|
*/
|
|
66
66
|
export const big = (...children) => h('big', ...children)
|
|
67
67
|
|
|
@@ -70,6 +70,11 @@ export const big = (...children) => h('big', ...children)
|
|
|
70
70
|
*/
|
|
71
71
|
export const blockquote = (...children) => h('blockquote', ...children)
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @type {function(...[*]=): HTMLBodyElement}
|
|
75
|
+
*/
|
|
76
|
+
export const body = (...children) => h('body', ...children)
|
|
77
|
+
|
|
73
78
|
/**
|
|
74
79
|
* @type {function(...[*]=): HTMLBRElement}
|
|
75
80
|
*/
|
|
@@ -91,12 +96,12 @@ export const canvas = (...children) => h('canvas', ...children)
|
|
|
91
96
|
export const caption = (...children) => h('caption', ...children)
|
|
92
97
|
|
|
93
98
|
/**
|
|
94
|
-
* @type {function(...[*]=):
|
|
99
|
+
* @type {function(...[*]=): HTMLElement}
|
|
95
100
|
*/
|
|
96
101
|
export const cite = (...children) => h('cite', ...children)
|
|
97
102
|
|
|
98
103
|
/**
|
|
99
|
-
* @type {function(...[*]=):
|
|
104
|
+
* @type {function(...[*]=): HTMLElement}
|
|
100
105
|
*/
|
|
101
106
|
export const code = (...children) => h('code', ...children)
|
|
102
107
|
|
|
@@ -121,7 +126,7 @@ export const data = (...children) => h('data', ...children)
|
|
|
121
126
|
export const datalist = (...children) => h('datalist', ...children)
|
|
122
127
|
|
|
123
128
|
/**
|
|
124
|
-
* @type {function(...[*]=):
|
|
129
|
+
* @type {function(...[*]=): HTMLElement}
|
|
125
130
|
*/
|
|
126
131
|
export const dd = (...children) => h('dd', ...children)
|
|
127
132
|
|
|
@@ -136,7 +141,7 @@ export const del = (...children) => h('del', ...children)
|
|
|
136
141
|
export const details = (...children) => h('details', ...children)
|
|
137
142
|
|
|
138
143
|
/**
|
|
139
|
-
* @type {function(...[*]=):
|
|
144
|
+
* @type {function(...[*]=): HTMLElement}
|
|
140
145
|
*/
|
|
141
146
|
export const dfn = (...children) => h('dfn', ...children)
|
|
142
147
|
|
|
@@ -145,6 +150,11 @@ export const dfn = (...children) => h('dfn', ...children)
|
|
|
145
150
|
*/
|
|
146
151
|
export const dialog = (...children) => h('dialog', ...children)
|
|
147
152
|
|
|
153
|
+
/**
|
|
154
|
+
* @type {function(...[*]=): HTMLDirectoryElement}
|
|
155
|
+
*/
|
|
156
|
+
export const dir = (...children) => h('dir', ...children)
|
|
157
|
+
|
|
148
158
|
/**
|
|
149
159
|
* @type {function(...[*]=): HTMLDivElement}
|
|
150
160
|
*/
|
|
@@ -156,12 +166,12 @@ export const div = (...children) => h('div', ...children)
|
|
|
156
166
|
export const dl = (...children) => h('dl', ...children)
|
|
157
167
|
|
|
158
168
|
/**
|
|
159
|
-
* @type {function(...[*]=):
|
|
169
|
+
* @type {function(...[*]=): HTMLElement}
|
|
160
170
|
*/
|
|
161
171
|
export const dt = (...children) => h('dt', ...children)
|
|
162
172
|
|
|
163
173
|
/**
|
|
164
|
-
* @type {function(...[*]=):
|
|
174
|
+
* @type {function(...[*]=): HTMLElement}
|
|
165
175
|
*/
|
|
166
176
|
export const em = (...children) => h('em', ...children)
|
|
167
177
|
|
|
@@ -176,12 +186,12 @@ export const embed = (...children) => h('embed', ...children)
|
|
|
176
186
|
export const fieldset = (...children) => h('fieldset', ...children)
|
|
177
187
|
|
|
178
188
|
/**
|
|
179
|
-
* @type {function(...[*]=):
|
|
189
|
+
* @type {function(...[*]=): HTMLElement}
|
|
180
190
|
*/
|
|
181
191
|
export const figcaption = (...children) => h('figcaption', ...children)
|
|
182
192
|
|
|
183
193
|
/**
|
|
184
|
-
* @type {function(...[*]=):
|
|
194
|
+
* @type {function(...[*]=): HTMLElement}
|
|
185
195
|
*/
|
|
186
196
|
export const figure = (...children) => h('figure', ...children)
|
|
187
197
|
|
|
@@ -236,7 +246,12 @@ export const flexCenteredRow = (...children) => styled(
|
|
|
236
246
|
)
|
|
237
247
|
|
|
238
248
|
/**
|
|
239
|
-
* @type {function(...[*]=):
|
|
249
|
+
* @type {function(...[*]=): HTMLFontElement}
|
|
250
|
+
*/
|
|
251
|
+
export const font = (...children) => h(font, ...children)
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @type {function(...[*]=): HTMLElement}
|
|
240
255
|
*/
|
|
241
256
|
export const footer = (...children) => h('footer', ...children)
|
|
242
257
|
|
|
@@ -286,17 +301,32 @@ export const h5 = (...children) => h('h5', ...children)
|
|
|
286
301
|
export const h6 = (...children) => h('h6', ...children)
|
|
287
302
|
|
|
288
303
|
/**
|
|
289
|
-
* @type {function(...[*]=):
|
|
304
|
+
* @type {function(...[*]=): HTMLHeadElement}
|
|
305
|
+
*/
|
|
306
|
+
export const head = (...children) => h('head', ...children)
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* @type {function(...[*]=): HTMLElement}
|
|
290
310
|
*/
|
|
291
311
|
export const header = (...children) => h('header', ...children)
|
|
292
312
|
|
|
313
|
+
/**
|
|
314
|
+
* @type {function(...[*]=): HTMLElement}
|
|
315
|
+
*/
|
|
316
|
+
export const hgroup = (...children) => h('hgroup', ...children)
|
|
317
|
+
|
|
293
318
|
/**
|
|
294
319
|
* @type {function(...[*]=): HTMLHRElement}
|
|
295
320
|
*/
|
|
296
321
|
export const hr = (...children) => h('hr', ...children)
|
|
297
322
|
|
|
298
323
|
/**
|
|
299
|
-
* @type {function(...[*]=):
|
|
324
|
+
* @type {function(...[*]=): HTMLHtmlElement}
|
|
325
|
+
*/
|
|
326
|
+
export const html = (...children) => h('html', ...children)
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @type {function(...[*]=): HTMLElement}
|
|
300
330
|
*/
|
|
301
331
|
export const i = (...children) => h('i', ...children)
|
|
302
332
|
|
|
@@ -321,7 +351,7 @@ export const input = (...children) => h('input', ...children)
|
|
|
321
351
|
export const ins = (...children) => h('ins', ...children)
|
|
322
352
|
|
|
323
353
|
/**
|
|
324
|
-
* @type {function(...[*]=):
|
|
354
|
+
* @type {function(...[*]=): HTMLElement}
|
|
325
355
|
*/
|
|
326
356
|
export const kbd = (...children) => h('kbd', ...children)
|
|
327
357
|
|
|
@@ -346,7 +376,7 @@ export const li = (...children) => h('li', ...children)
|
|
|
346
376
|
export const link = (...children) => h('link', ...children)
|
|
347
377
|
|
|
348
378
|
/**
|
|
349
|
-
* @type {function(...[*]=):
|
|
379
|
+
* @type {function(...[*]=): HTMLElement}
|
|
350
380
|
*/
|
|
351
381
|
export const main = (...children) => h('main', ...children)
|
|
352
382
|
|
|
@@ -356,13 +386,13 @@ export const main = (...children) => h('main', ...children)
|
|
|
356
386
|
export const map = (...children) => h('map', ...children)
|
|
357
387
|
|
|
358
388
|
/**
|
|
359
|
-
* @type {function(...[*]=):
|
|
389
|
+
* @type {function(...[*]=): HTMLElement}
|
|
360
390
|
*/
|
|
361
391
|
export const mark = (...children) => h('mark', ...children)
|
|
362
392
|
|
|
363
393
|
/**
|
|
364
394
|
* The best html element for every occasion.
|
|
365
|
-
* @type {function(...[*]=):
|
|
395
|
+
* @type {function(...[*]=): HTMLMarqueeElement}
|
|
366
396
|
*/
|
|
367
397
|
export const marquee = (...children) => h('marquee', ...children)
|
|
368
398
|
|
|
@@ -382,17 +412,17 @@ export const meta = (...children) => h('meta', ...children)
|
|
|
382
412
|
export const meter = (...children) => h('meter', ...children)
|
|
383
413
|
|
|
384
414
|
/**
|
|
385
|
-
* @type {function(...[*]=):
|
|
415
|
+
* @type {function(...[*]=): HTMLElement}
|
|
386
416
|
*/
|
|
387
417
|
export const nav = (...children) => h('nav', ...children)
|
|
388
418
|
|
|
389
419
|
/**
|
|
390
|
-
* @type {function(...[*]=):
|
|
420
|
+
* @type {function(...[*]=): HTMLElement}
|
|
391
421
|
*/
|
|
392
422
|
export const noframes = (...children) => h('noframes', ...children)
|
|
393
423
|
|
|
394
424
|
/**
|
|
395
|
-
* @type {function(...[*]=):
|
|
425
|
+
* @type {function(...[*]=): HTMLElement}
|
|
396
426
|
*/
|
|
397
427
|
export const noscript = (...children) => h('noscript', ...children)
|
|
398
428
|
|
|
@@ -452,22 +482,27 @@ export const progress = (...children) => h('progress', ...children)
|
|
|
452
482
|
export const q = (...children) => h('q', ...children)
|
|
453
483
|
|
|
454
484
|
/**
|
|
455
|
-
* @type {function(...[*]=):
|
|
485
|
+
* @type {function(...[*]=): HTMLElement}
|
|
456
486
|
*/
|
|
457
487
|
export const rp = (...children) => h('rp', ...children)
|
|
458
488
|
|
|
459
489
|
/**
|
|
460
|
-
* @type {function(...[*]=):
|
|
490
|
+
* @type {function(...[*]=): HTMLElement}
|
|
461
491
|
*/
|
|
462
492
|
export const rt = (...children) => h('rt', ...children)
|
|
463
493
|
|
|
464
494
|
/**
|
|
465
|
-
* @type {function(...[*]=):
|
|
495
|
+
* @type {function(...[*]=): HTMLElement}
|
|
466
496
|
*/
|
|
467
497
|
export const ruby = (...children) => h('ruby', ...children)
|
|
468
498
|
|
|
469
499
|
/**
|
|
470
|
-
* @type {function(...[*]=):
|
|
500
|
+
* @type {function(...[*]=): HTMLElement}
|
|
501
|
+
*/
|
|
502
|
+
export const s = (...children) => h('s', ...children)
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* @type {function(...[*]=): HTMLElement}
|
|
471
506
|
*/
|
|
472
507
|
export const samp = (...children) => h('samp', ...children)
|
|
473
508
|
|
|
@@ -477,7 +512,7 @@ export const samp = (...children) => h('samp', ...children)
|
|
|
477
512
|
export const script = (...children) => h('script', ...children)
|
|
478
513
|
|
|
479
514
|
/**
|
|
480
|
-
* @type {function(...[*]=):
|
|
515
|
+
* @type {function(...[*]=): HTMLElement}
|
|
481
516
|
*/
|
|
482
517
|
export const section = (...children) => h('section', ...children)
|
|
483
518
|
|
|
@@ -487,7 +522,12 @@ export const section = (...children) => h('section', ...children)
|
|
|
487
522
|
export const select = (...children) => h('select', ...children)
|
|
488
523
|
|
|
489
524
|
/**
|
|
490
|
-
* @type {function(...[*]=):
|
|
525
|
+
* @type {function(...[*]=): HTMLSlotElement}
|
|
526
|
+
*/
|
|
527
|
+
export const slot = (...children) => h('slot', ...children)
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* @type {function(...[*]=): HTMLElement}
|
|
491
531
|
*/
|
|
492
532
|
export const small = (...children) => h('small', ...children)
|
|
493
533
|
|
|
@@ -502,7 +542,7 @@ export const source = (...children) => h('source', ...children)
|
|
|
502
542
|
export const span = (...children) => h('span', ...children)
|
|
503
543
|
|
|
504
544
|
/**
|
|
505
|
-
* @type {function(...[*]=):
|
|
545
|
+
* @type {function(...[*]=): HTMLElement}
|
|
506
546
|
*/
|
|
507
547
|
export const strong = (...children) => h('strong', ...children)
|
|
508
548
|
|
|
@@ -512,25 +552,20 @@ export const strong = (...children) => h('strong', ...children)
|
|
|
512
552
|
export const style = (...children) => h('style', ...children)
|
|
513
553
|
|
|
514
554
|
/**
|
|
515
|
-
* @type {function(...[*]=):
|
|
555
|
+
* @type {function(...[*]=): HTMLElement}
|
|
516
556
|
*/
|
|
517
557
|
export const sub = (...children) => h('sub', ...children)
|
|
518
558
|
|
|
519
559
|
/**
|
|
520
|
-
* @type {function(...[*]=):
|
|
560
|
+
* @type {function(...[*]=): HTMLElement}
|
|
521
561
|
*/
|
|
522
562
|
export const summary = (...children) => h('summary', ...children)
|
|
523
563
|
|
|
524
564
|
/**
|
|
525
|
-
* @type {function(...[*]=):
|
|
565
|
+
* @type {function(...[*]=): HTMLElement}
|
|
526
566
|
*/
|
|
527
567
|
export const sup = (...children) => h('sup', ...children)
|
|
528
568
|
|
|
529
|
-
/**
|
|
530
|
-
* @type {function(...[*]=): ( ...children) => h}
|
|
531
|
-
*/
|
|
532
|
-
export const svg = (...children) => h('ns=http://www.w3.org/2000/svg|svg', ...children)
|
|
533
|
-
|
|
534
569
|
/**
|
|
535
570
|
* @type {function(...[*]=): HTMLTableElement}
|
|
536
571
|
*/
|
|
@@ -592,24 +627,26 @@ export const tr = (...children) => h('tr', ...children)
|
|
|
592
627
|
export const track = (...children) => h('track', ...children)
|
|
593
628
|
|
|
594
629
|
/**
|
|
595
|
-
* @type {function(...[*]=):
|
|
630
|
+
* @type {function(...[*]=): HTMLElement}
|
|
596
631
|
*/
|
|
597
632
|
export const tt = (...children) => h('tt', ...children)
|
|
598
633
|
|
|
599
634
|
/**
|
|
600
|
-
* @type {function(...[*]=):
|
|
635
|
+
* @type {function(...[*]=): HTMLElement}
|
|
601
636
|
*/
|
|
602
|
-
export const
|
|
637
|
+
export const u = (...children) => h('u', ...children)
|
|
603
638
|
|
|
604
639
|
/**
|
|
605
|
-
* @type {function(...[*]=):
|
|
640
|
+
* @type {function(...[*]=): HTMLUListElement}
|
|
606
641
|
*/
|
|
607
|
-
export const
|
|
642
|
+
export const ul = (...children) => h('ul', ...children)
|
|
608
643
|
|
|
609
644
|
/**
|
|
610
|
-
*
|
|
645
|
+
* name conflicts with js syntax
|
|
646
|
+
*
|
|
647
|
+
* @type {function(...[*]=): HTMLElement}
|
|
611
648
|
*/
|
|
612
|
-
export const
|
|
649
|
+
export const var_ = (...children) => h('var', ...children)
|
|
613
650
|
|
|
614
651
|
/**
|
|
615
652
|
* @type {function(...[*]=): HTMLVideoElement}
|
|
@@ -617,6 +654,6 @@ export const _var = (...children) => h('var', ...children)
|
|
|
617
654
|
export const video = (...children) => h('video', ...children)
|
|
618
655
|
|
|
619
656
|
/**
|
|
620
|
-
* @type {function(...[*]=):
|
|
657
|
+
* @type {function(...[*]=): HTMLElement}
|
|
621
658
|
*/
|
|
622
659
|
export const wbr = (...children) => h('wbr', ...children)
|
package/src/fntags.mjs
CHANGED
|
@@ -20,8 +20,11 @@
|
|
|
20
20
|
export function h (tag, ...children) {
|
|
21
21
|
let firstChildIdx = 0
|
|
22
22
|
let element
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const nsIndex = hasNs(tag)
|
|
24
|
+
if (nsIndex > -1) {
|
|
25
|
+
const { ns, val } = splitNs(tag, nsIndex)
|
|
26
|
+
console.log(ns, val)
|
|
27
|
+
element = document.createElementNS(ns, val)
|
|
25
28
|
} else {
|
|
26
29
|
element = document.createElement(tag)
|
|
27
30
|
}
|
|
@@ -29,9 +32,21 @@ export function h (tag, ...children) {
|
|
|
29
32
|
if (isAttrs(children[firstChildIdx])) {
|
|
30
33
|
const attrs = children[firstChildIdx]
|
|
31
34
|
firstChildIdx += 1
|
|
35
|
+
let hasValue = false
|
|
32
36
|
for (const a in attrs) {
|
|
37
|
+
// set value last to ensure value constraints are set before trying to set the value to avoid modification
|
|
38
|
+
// For example, when using a range and specifying a min and max
|
|
39
|
+
// if the value is set first and is outside the default 1 to 100 range
|
|
40
|
+
// the value will be adjusted to be within the range, even though the value attribute will be set correctly
|
|
41
|
+
if (a === 'value') {
|
|
42
|
+
hasValue = true
|
|
43
|
+
continue
|
|
44
|
+
}
|
|
33
45
|
setAttribute(a, attrs[a], element)
|
|
34
46
|
}
|
|
47
|
+
if (hasValue) {
|
|
48
|
+
setAttribute('value', attrs.value, element)
|
|
49
|
+
}
|
|
35
50
|
}
|
|
36
51
|
for (let i = firstChildIdx; i < children.length; i++) {
|
|
37
52
|
const child = children[i]
|
|
@@ -46,6 +61,14 @@ export function h (tag, ...children) {
|
|
|
46
61
|
return element
|
|
47
62
|
}
|
|
48
63
|
|
|
64
|
+
function splitNs (val, i) {
|
|
65
|
+
return { ns: val.slice(0, i), val: val.slice(i + 1) }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function hasNs (val) {
|
|
69
|
+
return val.lastIndexOf(':')
|
|
70
|
+
}
|
|
71
|
+
|
|
49
72
|
/**
|
|
50
73
|
* Create a compiled template function. The returned function takes a single object that contains the properties
|
|
51
74
|
* defined in the template.
|
|
@@ -488,7 +511,7 @@ function keyMapper (mapKey, value) {
|
|
|
488
511
|
}
|
|
489
512
|
|
|
490
513
|
function arrangeElements (ctx, bindContext, oldState) {
|
|
491
|
-
if (ctx
|
|
514
|
+
if (!ctx?.currentValue?.length) {
|
|
492
515
|
bindContext.parent.textContent = ''
|
|
493
516
|
bindContext.boundElementByKey = {}
|
|
494
517
|
ctx.selectObservers = {}
|
|
@@ -661,13 +684,9 @@ const setAttribute = function (attrName, attr, element) {
|
|
|
661
684
|
for (const style in attr) {
|
|
662
685
|
setStyle(style, attr[style], element)
|
|
663
686
|
}
|
|
664
|
-
} else if (attrName === 'class') {
|
|
687
|
+
} else if (element.__fnselector && element.className && attrName === 'class') {
|
|
665
688
|
// special handling for class to ensure the selector classes from fntemplate don't get overwritten
|
|
666
|
-
|
|
667
|
-
element.className += ` ${attr}`
|
|
668
|
-
} else {
|
|
669
|
-
element.className = attr
|
|
670
|
-
}
|
|
689
|
+
element.className += ` ${attr}`
|
|
671
690
|
} else if (attrName === 'value') {
|
|
672
691
|
element.setAttribute('value', attr)
|
|
673
692
|
// html5 nodes like range don't update unless the value property on the object is set
|
|
@@ -675,11 +694,14 @@ const setAttribute = function (attrName, attr, element) {
|
|
|
675
694
|
} else if (booleanAttributes[attrName]) {
|
|
676
695
|
element[attrName] = !!attr
|
|
677
696
|
} else {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
697
|
+
let ns = null
|
|
698
|
+
const nsIndex = hasNs(attrName)
|
|
699
|
+
if (nsIndex > -1) {
|
|
700
|
+
const split = splitNs(attrName, nsIndex)
|
|
701
|
+
ns = split.ns
|
|
702
|
+
attrName = split.val
|
|
682
703
|
}
|
|
704
|
+
element.setAttributeNS(ns, attrName, attr)
|
|
683
705
|
}
|
|
684
706
|
}
|
|
685
707
|
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { h } from './fntags.mjs'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* name conflicts with html a
|
|
5
|
+
*
|
|
6
|
+
* @type {function(...[*]=): SVGAElement}
|
|
7
|
+
*/
|
|
8
|
+
export const a_ = (...children) => h('http://www.w3.org/2000/svg:a', ...children)
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @type {function(...[*]=): SVGCircleElement}
|
|
12
|
+
*/
|
|
13
|
+
export const circle = (...children) => h('http://www.w3.org/2000/svg:circle', ...children)
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @type {function(...[*]=): SVGClipPathElement}
|
|
17
|
+
*/
|
|
18
|
+
export const clipPath = (...children) => h('http://www.w3.org/2000/svg:clipPath', ...children)
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @type {function(...[*]=): SVGDefsElement}
|
|
22
|
+
*/
|
|
23
|
+
export const defs = (...children) => h('http://www.w3.org/2000/svg:defs', ...children)
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @type {function(...[*]=): SVGDescElement}
|
|
27
|
+
*/
|
|
28
|
+
export const desc = (...children) => h('http://www.w3.org/2000/svg:desc', ...children)
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @type {function(...[*]=): SVGEllipseElement}
|
|
32
|
+
*/
|
|
33
|
+
export const ellipse = (...children) => h('http://www.w3.org/2000/svg:ellipse', ...children)
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @type {function(...[*]=): SVGFEBlendElement}
|
|
37
|
+
*/
|
|
38
|
+
export const feBlend = (...children) => h('http://www.w3.org/2000/svg:feBlend', ...children)
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @type {function(...[*]=): SVGFEColorMatrixElement}
|
|
42
|
+
*/
|
|
43
|
+
export const feColorMatrix = (...children) => h('http://www.w3.org/2000/svg:feColorMatrix', ...children)
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @type {function(...[*]=): SVGFEComponentTransferElement}
|
|
47
|
+
*/
|
|
48
|
+
export const feComponentTransfer = (...children) => h('http://www.w3.org/2000/svg:feComponentTransfer', ...children)
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @type {function(...[*]=): SVGFECompositeElement}
|
|
52
|
+
*/
|
|
53
|
+
export const feComposite = (...children) => h('http://www.w3.org/2000/svg:feComposite', ...children)
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @type {function(...[*]=): SVGFEConvolveMatrixElement}
|
|
57
|
+
*/
|
|
58
|
+
export const feConvolveMatrix = (...children) => h('http://www.w3.org/2000/svg:feConvolveMatrix', ...children)
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @type {function(...[*]=): SVGFEDiffuseLightingElement}
|
|
62
|
+
*/
|
|
63
|
+
export const feDiffuseLighting = (...children) => h('http://www.w3.org/2000/svg:feDiffuseLighting', ...children)
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @type {function(...[*]=): SVGFEDisplacementMapElement}
|
|
67
|
+
*/
|
|
68
|
+
export const feDisplacementMap = (...children) => h('http://www.w3.org/2000/svg:feDisplacementMap', ...children)
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @type {function(...[*]=): SVGFEDistantLightElement}
|
|
72
|
+
*/
|
|
73
|
+
export const feDistantLight = (...children) => h('http://www.w3.org/2000/svg:feDistantLight', ...children)
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @type {function(...[*]=): SVGFEFloodElement}
|
|
77
|
+
*/
|
|
78
|
+
export const feFlood = (...children) => h('http://www.w3.org/2000/svg:feFlood', ...children)
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @type {function(...[*]=): SVGFEFuncAElement}
|
|
82
|
+
*/
|
|
83
|
+
export const feFuncA = (...children) => h('http://www.w3.org/2000/svg:feFuncA', ...children)
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @type {function(...[*]=): SVGFEFuncBElement}
|
|
87
|
+
*/
|
|
88
|
+
export const feFuncB = (...children) => h('http://www.w3.org/2000/svg:feFuncB', ...children)
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @type {function(...[*]=): SVGFEFuncGElement}
|
|
92
|
+
*/
|
|
93
|
+
export const feFuncG = (...children) => h('http://www.w3.org/2000/svg:feFuncG', ...children)
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @type {function(...[*]=): SVGFEFuncRElement}
|
|
97
|
+
*/
|
|
98
|
+
export const feFuncR = (...children) => h('http://www.w3.org/2000/svg:feFuncR', ...children)
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @type {function(...[*]=): SVGFEGaussianBlurElement}
|
|
102
|
+
*/
|
|
103
|
+
export const feGaussianBlur = (...children) => h('http://www.w3.org/2000/svg:feGaussianBlur', ...children)
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @type {function(...[*]=): SVGFEImageElement}
|
|
107
|
+
*/
|
|
108
|
+
export const feImage = (...children) => h('http://www.w3.org/2000/svg:feImage', ...children)
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @type {function(...[*]=): SVGFEMergeElement}
|
|
112
|
+
*/
|
|
113
|
+
export const feMerge = (...children) => h('http://www.w3.org/2000/svg:feMerge', ...children)
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @type {function(...[*]=): SVGFEMergeNodeElement}
|
|
117
|
+
*/
|
|
118
|
+
export const feMergeNode = (...children) => h('http://www.w3.org/2000/svg:feMergeNode', ...children)
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @type {function(...[*]=): SVGFEMorphologyElement}
|
|
122
|
+
*/
|
|
123
|
+
export const feMorphology = (...children) => h('http://www.w3.org/2000/svg:feMorphology', ...children)
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @type {function(...[*]=): SVGFEOffsetElement}
|
|
127
|
+
*/
|
|
128
|
+
export const feOffset = (...children) => h('http://www.w3.org/2000/svg:feOffset', ...children)
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @type {function(...[*]=): SVGFEPointLightElement}
|
|
132
|
+
*/
|
|
133
|
+
export const fePointLight = (...children) => h('http://www.w3.org/2000/svg:fePointLight', ...children)
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @type {function(...[*]=): SVGFESpecularLightingElement}
|
|
137
|
+
*/
|
|
138
|
+
export const feSpecularLighting = (...children) => h('http://www.w3.org/2000/svg:feSpecularLighting', ...children)
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @type {function(...[*]=): SVGFESpotLightElement}
|
|
142
|
+
*/
|
|
143
|
+
export const feSpotLight = (...children) => h('http://www.w3.org/2000/svg:feSpotLight', ...children)
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @type {function(...[*]=): SVGFETileElement}
|
|
147
|
+
*/
|
|
148
|
+
export const feTile = (...children) => h('http://www.w3.org/2000/svg:feTile', ...children)
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @type {function(...[*]=): SVGFETurbulenceElement}
|
|
152
|
+
*/
|
|
153
|
+
export const feTurbulence = (...children) => h('http://www.w3.org/2000/svg:feTurbulence', ...children)
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @type {function(...[*]=): SVGFilterElement}
|
|
157
|
+
*/
|
|
158
|
+
export const filter = (...children) => h('http://www.w3.org/2000/svg:filter', ...children)
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @type {function(...[*]=): SVGForeignObjectElement}
|
|
162
|
+
*/
|
|
163
|
+
export const foreignObject = (...children) => h('http://www.w3.org/2000/svg:foreignObject', ...children)
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @type {function(...[*]=): SVGGElement}
|
|
167
|
+
*/
|
|
168
|
+
export const g = (...children) => h('http://www.w3.org/2000/svg:g', ...children)
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @type {function(...[*]=): SVGImageElement}
|
|
172
|
+
*/
|
|
173
|
+
export const image = (...children) => h('http://www.w3.org/2000/svg:image', ...children)
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @type {function(...[*]=): SVGLineElement}
|
|
177
|
+
*/
|
|
178
|
+
export const line = (...children) => h('http://www.w3.org/2000/svg:line', ...children)
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @type {function(...[*]=): SVGLinearGradientElement}
|
|
182
|
+
*/
|
|
183
|
+
export const linearGradient = (...children) => h('http://www.w3.org/2000/svg:linearGradient', ...children)
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @type {function(...[*]=): SVGMarkerElement}
|
|
187
|
+
*/
|
|
188
|
+
export const marker = (...children) => h('http://www.w3.org/2000/svg:marker', ...children)
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @type {function(...[*]=): SVGMaskElement}
|
|
192
|
+
*/
|
|
193
|
+
export const mask = (...children) => h('http://www.w3.org/2000/svg:mask', ...children)
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @type {function(...[*]=): SVGMetadataElement}
|
|
197
|
+
*/
|
|
198
|
+
export const metadata = (...children) => h('http://www.w3.org/2000/svg:metadata', ...children)
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @type {function(...[*]=): SVGPathElement}
|
|
202
|
+
*/
|
|
203
|
+
export const path = (...children) => h('http://www.w3.org/2000/svg:path', ...children)
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @type {function(...[*]=): SVGPatternElement}
|
|
207
|
+
*/
|
|
208
|
+
export const pattern = (...children) => h('http://www.w3.org/2000/svg:pattern', ...children)
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @type {function(...[*]=): SVGPolygonElement}
|
|
212
|
+
*/
|
|
213
|
+
export const polygon = (...children) => h('http://www.w3.org/2000/svg:polygon', ...children)
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @type {function(...[*]=): SVGPolylineElement}
|
|
217
|
+
*/
|
|
218
|
+
export const polyline = (...children) => h('http://www.w3.org/2000/svg:polyline', ...children)
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @type {function(...[*]=): SVGRadialGradientElement}
|
|
222
|
+
*/
|
|
223
|
+
export const radialGradient = (...children) => h('http://www.w3.org/2000/svg:radialGradient', ...children)
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @type {function(...[*]=): SVGRectElement}
|
|
227
|
+
*/
|
|
228
|
+
export const rect = (...children) => h('http://www.w3.org/2000/svg:rect', ...children)
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* name conflicts with html script
|
|
232
|
+
*
|
|
233
|
+
* @type {function(...[*]=): SVGScriptElement}
|
|
234
|
+
*/
|
|
235
|
+
export const script_ = (...children) => h('http://www.w3.org/2000/svg:script', ...children)
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @type {function(...[*]=): SVGStopElement}
|
|
239
|
+
*/
|
|
240
|
+
export const stop = (...children) => h('http://www.w3.org/2000/svg:stop', ...children)
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* name conflicts with html style
|
|
244
|
+
*
|
|
245
|
+
* @type {function(...[*]=): SVGStyleElement}
|
|
246
|
+
*/
|
|
247
|
+
export const style_ = (...children) => h('http://www.w3.org/2000/svg:style', ...children)
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* @type {function(...[*]=): SVGElement}
|
|
251
|
+
*/
|
|
252
|
+
export const svg = (...children) => h('http://www.w3.org/2000/svg:svg', ...children)
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* name conflicts with js syntax
|
|
256
|
+
*
|
|
257
|
+
* @type {function(...[*]=): SVGSwitchElement}
|
|
258
|
+
*/
|
|
259
|
+
export const switch_ = (...children) => h('http://www.w3.org/2000/svg:switch', ...children)
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @type {function(...[*]=): SVGSymbolElement}
|
|
263
|
+
*/
|
|
264
|
+
export const symbol = (...children) => h('http://www.w3.org/2000/svg:symbol', ...children)
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @type {function(...[*]=): SVGTextElement}
|
|
268
|
+
*/
|
|
269
|
+
export const text = (...children) => h('http://www.w3.org/2000/svg:text', ...children)
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @type {function(...[*]=): SVGTextPathElement}
|
|
273
|
+
*/
|
|
274
|
+
export const textPath = (...children) => h('http://www.w3.org/2000/svg:textPath', ...children)
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @type {function(...[*]=): SVGTitleElement}
|
|
278
|
+
*/
|
|
279
|
+
export const title = (...children) => h('http://www.w3.org/2000/svg:title', ...children)
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @type {function(...[*]=): SVGTSpanElement}
|
|
283
|
+
*/
|
|
284
|
+
export const tspan = (...children) => h('http://www.w3.org/2000/svg:tspan', ...children)
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @type {function(...[*]=): SVGUseElement}
|
|
288
|
+
*/
|
|
289
|
+
export const use = (...children) => h('http://www.w3.org/2000/svg:use', ...children)
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* @type {function(...[*]=): SVGViewElement}
|
|
293
|
+
*/
|
|
294
|
+
export const view = (...children) => h('http://www.w3.org/2000/svg:view', ...children)
|