@burger-editor/frozen-patty 0.10.0 → 3.5.0-alpha.1

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.
Files changed (49) hide show
  1. package/README.md +26 -27
  2. package/{lib → dist}/frozen-patty.d.ts +4 -18
  3. package/dist/frozen-patty.js +43 -0
  4. package/dist/get-value.d.ts +10 -0
  5. package/dist/get-value.js +15 -0
  6. package/dist/get-values.d.ts +10 -0
  7. package/{lib/getValue.js → dist/get-values.js} +42 -34
  8. package/dist/get.d.ts +9 -0
  9. package/dist/get.js +19 -0
  10. package/dist/index.d.ts +13 -0
  11. package/dist/index.js +14 -0
  12. package/dist/set-value.d.ts +14 -0
  13. package/{lib/setValue.js → dist/set-value.js} +105 -106
  14. package/dist/set.d.ts +9 -0
  15. package/dist/set.js +59 -0
  16. package/dist/types.d.ts +6 -0
  17. package/dist/types.js +1 -0
  18. package/{lib/util.d.ts → dist/utils.d.ts} +2 -2
  19. package/dist/utils.js +25 -0
  20. package/package.json +34 -39
  21. package/LICENSE +0 -21
  22. package/lib/frozen-patty.d.ts.map +0 -1
  23. package/lib/frozen-patty.js +0 -47
  24. package/lib/frozen-patty.js.map +0 -1
  25. package/lib/get.d.ts +0 -4
  26. package/lib/get.d.ts.map +0 -1
  27. package/lib/get.js +0 -20
  28. package/lib/get.js.map +0 -1
  29. package/lib/getValue.d.ts +0 -10
  30. package/lib/getValue.d.ts.map +0 -1
  31. package/lib/getValue.js.map +0 -1
  32. package/lib/index.d.ts +0 -35
  33. package/lib/index.d.ts.map +0 -1
  34. package/lib/index.js +0 -55
  35. package/lib/index.js.map +0 -1
  36. package/lib/polyfill.d.ts +0 -1
  37. package/lib/polyfill.d.ts.map +0 -1
  38. package/lib/polyfill.js +0 -20
  39. package/lib/polyfill.js.map +0 -1
  40. package/lib/set.d.ts +0 -4
  41. package/lib/set.d.ts.map +0 -1
  42. package/lib/set.js +0 -56
  43. package/lib/set.js.map +0 -1
  44. package/lib/setValue.d.ts +0 -15
  45. package/lib/setValue.d.ts.map +0 -1
  46. package/lib/setValue.js.map +0 -1
  47. package/lib/util.d.ts.map +0 -1
  48. package/lib/util.js +0 -30
  49. package/lib/util.js.map +0 -1
@@ -1,40 +1,37 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
2
  * Set value to an element
5
3
  *
6
4
  * ```html
7
5
  * <div [target-attribute] data-[attr]="[name]:[target-attribute]"></div>
8
6
  * ```
9
- *
7
+ * @param el A target element
10
8
  * @param name A label name
11
9
  * @param datum A datum of value
12
- * @param el A target element
13
- * @param attr Field data attribute name
10
+ * @param attr Data attribute name for specifying the node that FrozenPatty treats as a field
11
+ * @param filter
14
12
  */
15
- function default_1(name, datum, el, attr, filter) {
16
- var bindingFormats = el.getAttribute("data-".concat(attr)) || '';
17
- for (var _i = 0, _a = bindingFormats.split(/\s*,\s*/); _i < _a.length; _i++) {
18
- var bindingFormat = _a[_i];
13
+ export function setValue(el, name, datum, attr = 'field', filter) {
14
+ const bindingFormats = el.getAttribute(`data-${attr}`) || '';
15
+ for (let bindingFormat of bindingFormats.split(/\s*,\s*/)) {
19
16
  bindingFormat = bindingFormat.trim();
20
17
  /**
21
18
  * 抽出した対象キー
22
19
  */
23
- var key = void 0;
20
+ let key;
24
21
  /**
25
22
  * 対象属性
26
23
  *
27
24
  * `null`の場合は`innerHTML`が対象となる
28
25
  * ただし要素がinput要素の場合は`value`に設定
29
26
  */
30
- var targetAttr = void 0;
27
+ let targetAttr;
31
28
  //
32
29
  // 対象属性名の抽出
33
30
  //
34
- if (/^[a-z_-](?:[a-z0-9_-])*:[a-z_-](?:[a-z0-9_-])*(?:\([a-z-]+\))?/i.test(bindingFormat)) {
35
- var splitKey = bindingFormat.split(':');
36
- key = splitKey[0].trim();
37
- targetAttr = splitKey[1].trim();
31
+ if (/^[_a-z-][\w-]*:[_a-z-][\w-]*(?:\([a-z-]+\))?/i.test(bindingFormat)) {
32
+ const splitKey = bindingFormat.split(':');
33
+ key = splitKey[0]?.trim() ?? '';
34
+ targetAttr = splitKey[1]?.trim() ?? '';
38
35
  }
39
36
  else {
40
37
  key = bindingFormat.trim();
@@ -57,8 +54,8 @@ function default_1(name, datum, el, attr, filter) {
57
54
  // style属性
58
55
  //
59
56
  if (/^style\([a-z-]+\)$/i.test(targetAttr)) {
60
- var cssPropertyName = targetAttr.replace(/^style\(([a-z-]+)\)$/i, '$1');
61
- var cssValue = void 0;
57
+ const cssPropertyName = targetAttr.replace(/^style\(([a-z-]+)\)$/i, '$1');
58
+ let cssValue;
62
59
  switch (cssPropertyName) {
63
60
  case 'background-image': {
64
61
  //
@@ -69,18 +66,18 @@ function default_1(name, datum, el, attr, filter) {
69
66
  // デモサーバーから本番サーバーへの移行ができなくなってしまうので避ける
70
67
  // 単純な文字列を流し込む(setAttributeを利用)
71
68
  // urlはマルチバイト文字や空白記号を含まないはずであるがエスケープする
72
- var url = encodeURI("".concat(datum));
73
- cssValue = "url(".concat(url, ")");
69
+ const url = encodeURI(`${datum}`);
70
+ cssValue = `url(${url})`;
74
71
  break;
75
72
  }
76
73
  //
77
74
  // TODO: 他にもvalueに単位が必要なケースなどに対応したい
78
75
  //
79
76
  default: {
80
- cssValue = "".concat(datum);
77
+ cssValue = `${datum}`;
81
78
  }
82
79
  }
83
- el.setAttribute('style', "".concat(cssPropertyName, ": ").concat(cssValue));
80
+ el.setAttribute('style', `${cssPropertyName}: ${cssValue}`);
84
81
  //
85
82
  // 属性
86
83
  //
@@ -90,7 +87,7 @@ function default_1(name, datum, el, attr, filter) {
90
87
  }
91
88
  else {
92
89
  // SVGElement or more
93
- el.setAttribute(targetAttr, "".concat(datum));
90
+ el.setAttribute(targetAttr, `${datum}`);
94
91
  }
95
92
  //
96
93
  // 属性指定がない場合
@@ -100,32 +97,27 @@ function default_1(name, datum, el, attr, filter) {
100
97
  if (el instanceof HTMLInputElement ||
101
98
  el instanceof HTMLSelectElement ||
102
99
  el instanceof HTMLTextAreaElement) {
103
- el.value = "".concat(datum);
100
+ el.value = `${datum}`;
104
101
  }
105
102
  else {
106
- el.innerHTML = "".concat(datum);
103
+ el.innerHTML = `${datum}`;
107
104
  }
108
105
  }
109
106
  }
110
107
  }
111
- exports.default = default_1;
112
108
  /**
113
109
  * Set attribute
114
- *
115
110
  * @param el Target HTML element
116
111
  * @param attr Attribute name
117
112
  * @param datum Datum
118
- *
119
113
  */
120
- // tslint:disable-next-line:cyclomatic-complexity
121
114
  function setAttribute(el, attr, datum) {
122
115
  if (datum == null) {
123
116
  el.removeAttribute(attr);
124
117
  return;
125
118
  }
126
119
  switch (attr) {
127
- // ⚠️ Dosen't test
128
- case 'contentediable': {
120
+ case 'contenteditable': {
129
121
  switch (datum) {
130
122
  case 'true':
131
123
  case '': {
@@ -145,7 +137,7 @@ function setAttribute(el, attr, datum) {
145
137
  el.dir = datum;
146
138
  break;
147
139
  }
148
- case 'auto':
140
+ // case 'auto':
149
141
  default: {
150
142
  el.removeAttribute(attr);
151
143
  }
@@ -166,7 +158,7 @@ function setAttribute(el, attr, datum) {
166
158
  el.draggable = false;
167
159
  break;
168
160
  }
169
- case 'auto':
161
+ // case 'auto':
170
162
  default: {
171
163
  el.removeAttribute(attr);
172
164
  }
@@ -182,17 +174,17 @@ function setAttribute(el, attr, datum) {
182
174
  break;
183
175
  }
184
176
  case 'tabindex': {
185
- var i = void 0;
177
+ let i;
186
178
  if (typeof datum === 'boolean') {
187
179
  i = datum ? 0 : -1;
188
180
  }
189
181
  else if (typeof datum === 'string') {
190
- i = parseInt(datum, 10);
182
+ i = Number.parseInt(datum, 10);
191
183
  }
192
184
  else {
193
185
  i = datum;
194
186
  }
195
- el.tabIndex = isNaN(i) ? -1 : Math.floor(i);
187
+ el.tabIndex = Number.isNaN(i) ? -1 : Math.floor(i);
196
188
  break;
197
189
  }
198
190
  case 'async': {
@@ -200,16 +192,17 @@ function setAttribute(el, attr, datum) {
200
192
  el.async = !!datum;
201
193
  }
202
194
  else {
203
- el.setAttribute(attr, "".concat(datum));
195
+ el.setAttribute(attr, `${datum}`);
204
196
  }
205
197
  break;
206
198
  }
207
199
  case 'autocomplete': {
208
200
  if (el instanceof HTMLInputElement || el instanceof HTMLFormElement) {
209
- el.autocomplete = datum ? "".concat(datum) : 'off';
201
+ // @ts-ignore
202
+ el.autocomplete = datum ? `${datum}` : 'off';
210
203
  }
211
204
  else {
212
- el.setAttribute(attr, "".concat(datum));
205
+ el.setAttribute(attr, `${datum}`);
213
206
  }
214
207
  break;
215
208
  }
@@ -221,7 +214,7 @@ function setAttribute(el, attr, datum) {
221
214
  el.autofocus = datum === '' ? true : !!datum;
222
215
  }
223
216
  else {
224
- el.setAttribute(attr, "".concat(datum));
217
+ el.setAttribute(attr, `${datum}`);
225
218
  }
226
219
  break;
227
220
  }
@@ -230,7 +223,7 @@ function setAttribute(el, attr, datum) {
230
223
  el.autoplay = datum === '' ? true : !!datum;
231
224
  }
232
225
  else {
233
- el.setAttribute(attr, "".concat(datum));
226
+ el.setAttribute(attr, `${datum}`);
234
227
  }
235
228
  break;
236
229
  }
@@ -239,14 +232,14 @@ function setAttribute(el, attr, datum) {
239
232
  el.checked = datum === '' ? true : !!datum;
240
233
  }
241
234
  else {
242
- el.setAttribute(attr, "".concat(datum));
235
+ el.setAttribute(attr, `${datum}`);
243
236
  }
244
237
  break;
245
238
  }
246
239
  case 'cols': {
247
240
  if (el instanceof HTMLTextAreaElement) {
248
- var cols = toInt(datum);
249
- if (isNaN(cols)) {
241
+ const cols = toInt(datum);
242
+ if (Number.isNaN(cols)) {
250
243
  el.removeAttribute(attr);
251
244
  }
252
245
  else {
@@ -254,14 +247,14 @@ function setAttribute(el, attr, datum) {
254
247
  }
255
248
  }
256
249
  else {
257
- el.setAttribute(attr, "".concat(datum));
250
+ el.setAttribute(attr, `${datum}`);
258
251
  }
259
252
  break;
260
253
  }
261
254
  case 'colspan': {
262
255
  if (el instanceof HTMLTableCellElement) {
263
- var colSpan = toInt(datum);
264
- if (isNaN(colSpan)) {
256
+ const colSpan = toInt(datum);
257
+ if (Number.isNaN(colSpan)) {
265
258
  el.removeAttribute(attr);
266
259
  }
267
260
  else {
@@ -269,7 +262,7 @@ function setAttribute(el, attr, datum) {
269
262
  }
270
263
  }
271
264
  else {
272
- el.setAttribute(attr, "".concat(datum));
265
+ el.setAttribute(attr, `${datum}`);
273
266
  }
274
267
  break;
275
268
  }
@@ -278,7 +271,7 @@ function setAttribute(el, attr, datum) {
278
271
  el.controls = datum === '' ? true : !!datum;
279
272
  }
280
273
  else {
281
- el.setAttribute(attr, "".concat(datum));
274
+ el.setAttribute(attr, `${datum}`);
282
275
  }
283
276
  break;
284
277
  }
@@ -287,7 +280,7 @@ function setAttribute(el, attr, datum) {
287
280
  el.default = datum === '' ? true : !!datum;
288
281
  }
289
282
  else {
290
- el.setAttribute(attr, "".concat(datum));
283
+ el.setAttribute(attr, `${datum}`);
291
284
  }
292
285
  break;
293
286
  }
@@ -296,7 +289,7 @@ function setAttribute(el, attr, datum) {
296
289
  el.defer = !!datum;
297
290
  }
298
291
  else {
299
- el.setAttribute(attr, "".concat(datum));
292
+ el.setAttribute(attr, `${datum}`);
300
293
  }
301
294
  break;
302
295
  }
@@ -311,28 +304,28 @@ function setAttribute(el, attr, datum) {
311
304
  el.disabled = datum === '' ? true : !!datum;
312
305
  }
313
306
  else {
314
- el.setAttribute(attr, "".concat(datum));
307
+ el.setAttribute(attr, `${datum}`);
315
308
  }
316
309
  break;
317
310
  }
318
311
  case 'download': {
319
312
  if (el instanceof HTMLAnchorElement) {
320
313
  if (datum || datum === '') {
321
- el.download = "".concat(datum);
314
+ el.download = `${datum}`;
322
315
  }
323
316
  else {
324
317
  el.removeAttribute(attr);
325
318
  }
326
319
  }
327
320
  else {
328
- el.setAttribute(attr, "".concat(datum));
321
+ el.setAttribute(attr, `${datum}`);
329
322
  }
330
323
  break;
331
324
  }
332
325
  case 'high': {
333
326
  if (el instanceof HTMLMeterElement) {
334
- var high = toInt(datum);
335
- if (isNaN(high)) {
327
+ const high = toInt(datum);
328
+ if (Number.isNaN(high)) {
336
329
  el.removeAttribute(attr);
337
330
  }
338
331
  else {
@@ -340,7 +333,7 @@ function setAttribute(el, attr, datum) {
340
333
  }
341
334
  }
342
335
  else {
343
- el.setAttribute(attr, "".concat(datum));
336
+ el.setAttribute(attr, `${datum}`);
344
337
  }
345
338
  break;
346
339
  }
@@ -349,7 +342,7 @@ function setAttribute(el, attr, datum) {
349
342
  el.isMap = datum === '' ? true : !!datum;
350
343
  }
351
344
  else {
352
- el.setAttribute(attr, "".concat(datum));
345
+ el.setAttribute(attr, `${datum}`);
353
346
  }
354
347
  break;
355
348
  }
@@ -358,14 +351,14 @@ function setAttribute(el, attr, datum) {
358
351
  el.loop = datum === '' ? true : !!datum;
359
352
  }
360
353
  else {
361
- el.setAttribute(attr, "".concat(datum));
354
+ el.setAttribute(attr, `${datum}`);
362
355
  }
363
356
  break;
364
357
  }
365
358
  case 'low': {
366
359
  if (el instanceof HTMLMeterElement) {
367
- var low = toInt(datum);
368
- if (isNaN(low)) {
360
+ const low = toInt(datum);
361
+ if (Number.isNaN(low)) {
369
362
  el.removeAttribute(attr);
370
363
  }
371
364
  else {
@@ -373,7 +366,7 @@ function setAttribute(el, attr, datum) {
373
366
  }
374
367
  }
375
368
  else {
376
- el.setAttribute(attr, "".concat(datum));
369
+ el.setAttribute(attr, `${datum}`);
377
370
  }
378
371
  break;
379
372
  }
@@ -381,8 +374,8 @@ function setAttribute(el, attr, datum) {
381
374
  if (el instanceof HTMLInputElement ||
382
375
  el instanceof HTMLMeterElement ||
383
376
  el instanceof HTMLProgressElement) {
384
- var max = toInt(datum);
385
- if (isNaN(max)) {
377
+ const max = toInt(datum);
378
+ if (Number.isNaN(max)) {
386
379
  el.removeAttribute(attr);
387
380
  }
388
381
  else {
@@ -390,14 +383,14 @@ function setAttribute(el, attr, datum) {
390
383
  }
391
384
  }
392
385
  else {
393
- el.setAttribute(attr, "".concat(datum));
386
+ el.setAttribute(attr, `${datum}`);
394
387
  }
395
388
  break;
396
389
  }
397
390
  case 'maxlength': {
398
391
  if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
399
- var maxLength = toInt(datum);
400
- if (isNaN(maxLength)) {
392
+ const maxLength = toInt(datum);
393
+ if (Number.isNaN(maxLength)) {
401
394
  el.removeAttribute(attr);
402
395
  }
403
396
  else {
@@ -405,14 +398,14 @@ function setAttribute(el, attr, datum) {
405
398
  }
406
399
  }
407
400
  else {
408
- el.setAttribute(attr, "".concat(datum));
401
+ el.setAttribute(attr, `${datum}`);
409
402
  }
410
403
  break;
411
404
  }
412
405
  case 'min': {
413
406
  if (el instanceof HTMLInputElement || el instanceof HTMLMeterElement) {
414
- var min = toInt(datum);
415
- if (isNaN(min)) {
407
+ const min = toInt(datum);
408
+ if (Number.isNaN(min)) {
416
409
  el.removeAttribute(attr);
417
410
  }
418
411
  else {
@@ -420,7 +413,7 @@ function setAttribute(el, attr, datum) {
420
413
  }
421
414
  }
422
415
  else {
423
- el.setAttribute(attr, "".concat(datum));
416
+ el.setAttribute(attr, `${datum}`);
424
417
  }
425
418
  break;
426
419
  }
@@ -429,7 +422,7 @@ function setAttribute(el, attr, datum) {
429
422
  el.multiple = datum === '' ? true : !!datum;
430
423
  }
431
424
  else {
432
- el.setAttribute(attr, "".concat(datum));
425
+ el.setAttribute(attr, `${datum}`);
433
426
  }
434
427
  break;
435
428
  }
@@ -438,14 +431,14 @@ function setAttribute(el, attr, datum) {
438
431
  el.noValidate = datum === '' ? true : !!datum;
439
432
  }
440
433
  else {
441
- el.setAttribute(attr, "".concat(datum));
434
+ el.setAttribute(attr, `${datum}`);
442
435
  }
443
436
  break;
444
437
  }
445
438
  // ⚰️ Unsupported HTMLDetailsElement yet...
446
- // case 'oepn': {
439
+ // case 'open': {
447
440
  // if (el instanceof HTMLDetailsElement) {
448
- // el.oepn = datum === '' ? true : !!datum;
441
+ // el.open = datum === '' ? true : !!datum;
449
442
  // } else {
450
443
  // el.setAttribute(attr, `${datum}`);
451
444
  // }
@@ -453,8 +446,8 @@ function setAttribute(el, attr, datum) {
453
446
  // }
454
447
  case 'optimum': {
455
448
  if (el instanceof HTMLMeterElement) {
456
- var optimum = toInt(datum);
457
- if (isNaN(optimum)) {
449
+ const optimum = toInt(datum);
450
+ if (Number.isNaN(optimum)) {
458
451
  el.removeAttribute(attr);
459
452
  }
460
453
  else {
@@ -462,7 +455,7 @@ function setAttribute(el, attr, datum) {
462
455
  }
463
456
  }
464
457
  else {
465
- el.setAttribute(attr, "".concat(datum));
458
+ el.setAttribute(attr, `${datum}`);
466
459
  }
467
460
  break;
468
461
  }
@@ -481,7 +474,7 @@ function setAttribute(el, attr, datum) {
481
474
  }
482
475
  }
483
476
  else {
484
- el.setAttribute(attr, "".concat(datum));
477
+ el.setAttribute(attr, `${datum}`);
485
478
  }
486
479
  break;
487
480
  }
@@ -490,7 +483,7 @@ function setAttribute(el, attr, datum) {
490
483
  el.readOnly = datum === '' ? true : !!datum;
491
484
  }
492
485
  else {
493
- el.setAttribute(attr, "".concat(datum));
486
+ el.setAttribute(attr, `${datum}`);
494
487
  }
495
488
  break;
496
489
  }
@@ -501,24 +494,23 @@ function setAttribute(el, attr, datum) {
501
494
  el.required = datum === '' ? true : !!datum;
502
495
  }
503
496
  else {
504
- el.setAttribute(attr, "".concat(datum));
497
+ el.setAttribute(attr, `${datum}`);
505
498
  }
506
499
  break;
507
500
  }
508
501
  case 'reversed': {
509
502
  if (el instanceof HTMLOListElement) {
510
- // tslint:disable-next-line:no-any
511
503
  el.reversed = datum === '' ? true : !!datum;
512
504
  }
513
505
  else {
514
- el.setAttribute(attr, "".concat(datum));
506
+ el.setAttribute(attr, `${datum}`);
515
507
  }
516
508
  break;
517
509
  }
518
510
  case 'rows': {
519
511
  if (el instanceof HTMLTextAreaElement) {
520
- var rows = toInt(datum);
521
- if (isNaN(rows)) {
512
+ const rows = toInt(datum);
513
+ if (Number.isNaN(rows)) {
522
514
  el.removeAttribute(attr);
523
515
  }
524
516
  else {
@@ -526,14 +518,14 @@ function setAttribute(el, attr, datum) {
526
518
  }
527
519
  }
528
520
  else {
529
- el.setAttribute(attr, "".concat(datum));
521
+ el.setAttribute(attr, `${datum}`);
530
522
  }
531
523
  break;
532
524
  }
533
525
  case 'rowspan': {
534
526
  if (el instanceof HTMLTableCellElement) {
535
- var rowSpan = toInt(datum);
536
- if (isNaN(rowSpan)) {
527
+ const rowSpan = toInt(datum);
528
+ if (Number.isNaN(rowSpan)) {
537
529
  el.removeAttribute(attr);
538
530
  }
539
531
  else {
@@ -541,14 +533,14 @@ function setAttribute(el, attr, datum) {
541
533
  }
542
534
  }
543
535
  else {
544
- el.setAttribute(attr, "".concat(datum));
536
+ el.setAttribute(attr, `${datum}`);
545
537
  }
546
538
  break;
547
539
  }
548
540
  case 'size': {
549
541
  if (el instanceof HTMLInputElement || el instanceof HTMLSelectElement) {
550
- var size = toInt(datum);
551
- if (isNaN(size)) {
542
+ const size = toInt(datum);
543
+ if (Number.isNaN(size)) {
552
544
  el.removeAttribute(attr);
553
545
  }
554
546
  else {
@@ -556,14 +548,14 @@ function setAttribute(el, attr, datum) {
556
548
  }
557
549
  }
558
550
  else {
559
- el.setAttribute(attr, "".concat(datum));
551
+ el.setAttribute(attr, `${datum}`);
560
552
  }
561
553
  break;
562
554
  }
563
555
  case 'span': {
564
556
  if (el instanceof HTMLTableColElement) {
565
- var span = toInt(datum);
566
- if (isNaN(span)) {
557
+ const span = toInt(datum);
558
+ if (Number.isNaN(span)) {
567
559
  el.removeAttribute(attr);
568
560
  }
569
561
  else {
@@ -571,14 +563,14 @@ function setAttribute(el, attr, datum) {
571
563
  }
572
564
  }
573
565
  else {
574
- el.setAttribute(attr, "".concat(datum));
566
+ el.setAttribute(attr, `${datum}`);
575
567
  }
576
568
  break;
577
569
  }
578
570
  case 'start': {
579
571
  if (el instanceof HTMLOListElement) {
580
- var start = toInt(datum);
581
- if (isNaN(start)) {
572
+ const start = toInt(datum);
573
+ if (Number.isNaN(start)) {
582
574
  el.removeAttribute(attr);
583
575
  }
584
576
  else {
@@ -586,7 +578,7 @@ function setAttribute(el, attr, datum) {
586
578
  }
587
579
  }
588
580
  else {
589
- el.setAttribute(attr, "".concat(datum));
581
+ el.setAttribute(attr, `${datum}`);
590
582
  }
591
583
  break;
592
584
  }
@@ -596,8 +588,8 @@ function setAttribute(el, attr, datum) {
596
588
  el.step = datum;
597
589
  break;
598
590
  }
599
- var step = toNum(datum);
600
- if (isNaN(step)) {
591
+ const step = toNum(datum);
592
+ if (Number.isNaN(step)) {
601
593
  el.removeAttribute(attr);
602
594
  }
603
595
  else {
@@ -605,7 +597,7 @@ function setAttribute(el, attr, datum) {
605
597
  }
606
598
  }
607
599
  else {
608
- el.setAttribute(attr, "".concat(datum));
600
+ el.setAttribute(attr, `${datum}`);
609
601
  }
610
602
  break;
611
603
  }
@@ -614,14 +606,14 @@ function setAttribute(el, attr, datum) {
614
606
  el instanceof HTMLAreaElement ||
615
607
  el instanceof HTMLFormElement) {
616
608
  if (datum) {
617
- el.target = "".concat(datum);
609
+ el.target = `${datum}`;
618
610
  }
619
611
  else {
620
612
  el.removeAttribute(attr);
621
613
  }
622
614
  }
623
615
  else {
624
- el.setAttribute(attr, "".concat(datum));
616
+ el.setAttribute(attr, `${datum}`);
625
617
  }
626
618
  break;
627
619
  }
@@ -675,24 +667,31 @@ function setAttribute(el, attr, datum) {
675
667
  // case 'wrap':
676
668
  // and Data-* attributes
677
669
  default: {
678
- el.setAttribute(attr, "".concat(datum));
670
+ el.setAttribute(attr, `${datum}`);
679
671
  }
680
672
  }
681
673
  }
674
+ /**
675
+ *
676
+ * @param datum
677
+ */
682
678
  function toNum(datum) {
683
- var i;
679
+ let i;
684
680
  if (typeof datum === 'boolean') {
685
681
  i = +datum;
686
682
  }
687
683
  else if (typeof datum === 'string') {
688
- i = parseFloat(datum);
684
+ i = Number.parseFloat(datum);
689
685
  }
690
686
  else {
691
687
  i = datum;
692
688
  }
693
689
  return i;
694
690
  }
691
+ /**
692
+ *
693
+ * @param datum
694
+ */
695
695
  function toInt(datum) {
696
696
  return Math.floor(toNum(datum));
697
697
  }
698
- //# sourceMappingURL=setValue.js.map
package/dist/set.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { Filter, FrozenPattyData } from './types.js';
2
+ /**
3
+ *
4
+ * @param el
5
+ * @param data
6
+ * @param attr
7
+ * @param filter
8
+ */
9
+ export default function (el: Element, data: FrozenPattyData, attr: string, filter?: Filter): Element;