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