@markuplint/types 4.0.0-alpha.1 → 4.0.0-alpha.10
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 +63 -61
- package/lib/css-syntax.js +16 -11
- package/lib/defs.d.ts +1 -0
- package/lib/defs.js +172 -52
- package/lib/enum.js +1 -1
- package/lib/get-candidate.js +2 -2
- package/lib/keyword-type.js +3 -3
- package/lib/number.d.ts +2 -2
- package/lib/number.js +2 -2
- package/lib/primitive/is-float.js +1 -1
- package/lib/primitive/is-int.js +1 -1
- package/lib/primitive/is-non-zero-uint.js +1 -1
- package/lib/primitive/is-uint.js +3 -3
- package/lib/primitive/range.js +2 -2
- package/lib/primitive/split-unit.js +1 -1
- package/lib/token/token-collection.d.ts +4 -5
- package/lib/token/token-collection.js +23 -18
- package/lib/token/token.d.ts +1 -1
- package/lib/token/token.js +9 -8
- package/lib/types.d.ts +1 -0
- package/lib/types.schema.d.ts +1 -1
- package/lib/w3c/check-serialized-permissions-policy.js +5 -5
- package/lib/whatwg/check-autocomplete.js +10 -13
- package/lib/whatwg/check-datetime/date-string.js +3 -3
- package/lib/whatwg/check-datetime/datetime-tokens.js +18 -18
- package/lib/whatwg/check-datetime/duration-string.js +30 -29
- package/lib/whatwg/check-datetime/global-date-and-time-string.js +8 -8
- package/lib/whatwg/check-datetime/local-date-and-time-string.js +17 -16
- package/lib/whatwg/check-datetime/month-string.js +1 -1
- package/lib/whatwg/check-datetime/time-string.js +4 -4
- package/lib/whatwg/check-datetime/time-zone-offset-string.js +6 -6
- package/lib/whatwg/check-datetime/week-string.js +2 -2
- package/lib/whatwg/check-datetime/yearless-date-string.js +2 -2
- package/lib/whatwg/is-abs-url.js +7 -7
- package/lib/whatwg/is-browser-context-name.d.ts +2 -0
- package/lib/whatwg/is-browser-context-name.js +2 -0
- package/lib/whatwg/is-custom-element-name.d.ts +9 -4
- package/lib/whatwg/is-custom-element-name.js +21 -33
- package/lib/whatwg/is-navigable-target-name.d.ts +11 -0
- package/lib/whatwg/is-navigable-target-name.js +20 -0
- package/package.json +12 -9
- package/types.schema.json +3 -0
|
@@ -21,7 +21,7 @@ export const datetimeTokenCheck = {
|
|
|
21
21
|
partName: 'year',
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
if (!year.
|
|
24
|
+
if (!year.matches(/^\d+$/)) {
|
|
25
25
|
return year.unmatched({
|
|
26
26
|
reason: 'unexpected-token',
|
|
27
27
|
expects: [],
|
|
@@ -56,7 +56,7 @@ export const datetimeTokenCheck = {
|
|
|
56
56
|
partName: 'month',
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
if (!month.
|
|
59
|
+
if (!month.matches(/^\d+$/)) {
|
|
60
60
|
return month.unmatched({
|
|
61
61
|
reason: 'unexpected-token',
|
|
62
62
|
expects: [],
|
|
@@ -99,7 +99,7 @@ export const datetimeTokenCheck = {
|
|
|
99
99
|
partName: 'date',
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
if (!date.
|
|
102
|
+
if (!date.matches(/^\d+$/)) {
|
|
103
103
|
return date.unmatched({
|
|
104
104
|
reason: 'unexpected-token',
|
|
105
105
|
expects: [],
|
|
@@ -140,7 +140,7 @@ export const datetimeTokenCheck = {
|
|
|
140
140
|
partName: 'hour',
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
if (!hour.
|
|
143
|
+
if (!hour.matches(/^\d+$/)) {
|
|
144
144
|
return hour.unmatched({
|
|
145
145
|
reason: 'unexpected-token',
|
|
146
146
|
expects: [],
|
|
@@ -174,7 +174,7 @@ export const datetimeTokenCheck = {
|
|
|
174
174
|
partName: 'minute',
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
|
-
if (!minute.
|
|
177
|
+
if (!minute.matches(/^\d+$/)) {
|
|
178
178
|
return minute.unmatched({
|
|
179
179
|
reason: 'unexpected-token',
|
|
180
180
|
expects: [],
|
|
@@ -208,7 +208,7 @@ export const datetimeTokenCheck = {
|
|
|
208
208
|
partName: 'second',
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
|
-
if (!second.
|
|
211
|
+
if (!second.matches(/^\d+$/)) {
|
|
212
212
|
return second.unmatched({
|
|
213
213
|
reason: 'unexpected-token',
|
|
214
214
|
expects: [],
|
|
@@ -242,14 +242,14 @@ export const datetimeTokenCheck = {
|
|
|
242
242
|
partName: 'fractional part',
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
|
-
if (!secondFP.
|
|
245
|
+
if (!secondFP.matches(/^\d+$/)) {
|
|
246
246
|
return secondFP.unmatched({
|
|
247
247
|
reason: 'unexpected-token',
|
|
248
248
|
expects: [],
|
|
249
249
|
partName: 'fractional part',
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
|
-
if (!(
|
|
252
|
+
if (!(secondFP.length > 0 && secondFP.length <= 3)) {
|
|
253
253
|
return secondFP.unmatched({
|
|
254
254
|
reason: { type: 'out-of-range-length-digit', gte: 1, lte: 3 },
|
|
255
255
|
expects: [],
|
|
@@ -268,7 +268,7 @@ export const datetimeTokenCheck = {
|
|
|
268
268
|
partName: 'week',
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
|
-
if (!week.
|
|
271
|
+
if (!week.matches(/^\d+$/)) {
|
|
272
272
|
return week.unmatched({
|
|
273
273
|
reason: 'unexpected-token',
|
|
274
274
|
expects: [],
|
|
@@ -303,7 +303,7 @@ export const datetimeTokenCheck = {
|
|
|
303
303
|
partName: 'datetime',
|
|
304
304
|
});
|
|
305
305
|
}
|
|
306
|
-
if (!hyphen.
|
|
306
|
+
if (!hyphen.matches('-')) {
|
|
307
307
|
return hyphen.unmatched({
|
|
308
308
|
reason: 'unexpected-token',
|
|
309
309
|
expects: [{ type: 'common', value: 'hyphen' }],
|
|
@@ -322,7 +322,7 @@ export const datetimeTokenCheck = {
|
|
|
322
322
|
partName: 'time',
|
|
323
323
|
});
|
|
324
324
|
}
|
|
325
|
-
if (!colon.
|
|
325
|
+
if (!colon.matches(':')) {
|
|
326
326
|
return colon.unmatched({
|
|
327
327
|
reason: 'unexpected-token',
|
|
328
328
|
expects: [{ type: 'common', value: 'colon' }],
|
|
@@ -339,7 +339,7 @@ export const datetimeTokenCheck = {
|
|
|
339
339
|
if (!colon || !colon.value) {
|
|
340
340
|
return matched();
|
|
341
341
|
}
|
|
342
|
-
if (!colon.
|
|
342
|
+
if (!colon.matches(':')) {
|
|
343
343
|
return colon.unmatched({
|
|
344
344
|
reason: 'unexpected-token',
|
|
345
345
|
expects: [{ type: 'common', value: 'colon' }],
|
|
@@ -356,7 +356,7 @@ export const datetimeTokenCheck = {
|
|
|
356
356
|
if (!dot || !dot.value) {
|
|
357
357
|
return matched();
|
|
358
358
|
}
|
|
359
|
-
if (!dot.
|
|
359
|
+
if (!dot.matches('.')) {
|
|
360
360
|
return dot.unmatched({
|
|
361
361
|
reason: 'unexpected-token',
|
|
362
362
|
expects: [{ type: 'common', value: 'decimal point' }],
|
|
@@ -377,7 +377,7 @@ export const datetimeTokenCheck = {
|
|
|
377
377
|
],
|
|
378
378
|
});
|
|
379
379
|
}
|
|
380
|
-
if (!sep.
|
|
380
|
+
if (!sep.matches(['T', ' '])) {
|
|
381
381
|
return sep.unmatched({
|
|
382
382
|
reason: 'unexpected-token',
|
|
383
383
|
expects: [
|
|
@@ -397,7 +397,7 @@ export const datetimeTokenCheck = {
|
|
|
397
397
|
expects: [{ type: 'const', value: 'T' }],
|
|
398
398
|
});
|
|
399
399
|
}
|
|
400
|
-
if (!sep.
|
|
400
|
+
if (!sep.matches('T')) {
|
|
401
401
|
return sep.unmatched({
|
|
402
402
|
reason: 'unexpected-token',
|
|
403
403
|
expects: [{ type: 'const', value: 'T' }],
|
|
@@ -420,7 +420,7 @@ export const datetimeTokenCheck = {
|
|
|
420
420
|
partName: 'time-zone',
|
|
421
421
|
});
|
|
422
422
|
}
|
|
423
|
-
if (!colon.
|
|
423
|
+
if (!colon.matches(['+', '-'])) {
|
|
424
424
|
return colon.unmatched({
|
|
425
425
|
reason: 'unexpected-token',
|
|
426
426
|
expects: [
|
|
@@ -442,7 +442,7 @@ export const datetimeTokenCheck = {
|
|
|
442
442
|
partName: 'time-zone',
|
|
443
443
|
});
|
|
444
444
|
}
|
|
445
|
-
if (!weekSign.
|
|
445
|
+
if (!weekSign.matches('W')) {
|
|
446
446
|
return weekSign.unmatched({
|
|
447
447
|
reason: 'unexpected-token',
|
|
448
448
|
expects: [{ type: 'const', value: 'W' }],
|
|
@@ -502,5 +502,5 @@ export function getMaxWeekNum(year) {
|
|
|
502
502
|
}
|
|
503
503
|
date--;
|
|
504
504
|
}
|
|
505
|
-
return NaN;
|
|
505
|
+
return Number.NaN;
|
|
506
506
|
}
|
|
@@ -10,11 +10,11 @@ export const checkDurationISO8601LikeString = () => function checkDurationISO860
|
|
|
10
10
|
// PnDTnHnMnS
|
|
11
11
|
const tokens = TokenCollection.fromPatterns(value, [
|
|
12
12
|
// Start sign P
|
|
13
|
-
/[
|
|
13
|
+
/[^\dT]?/,
|
|
14
14
|
// date part
|
|
15
15
|
/[^T]*/,
|
|
16
16
|
// Time sign T
|
|
17
|
-
|
|
17
|
+
/\D?/,
|
|
18
18
|
// Time part
|
|
19
19
|
/.*/,
|
|
20
20
|
]);
|
|
@@ -26,7 +26,7 @@ export const checkDurationISO8601LikeString = () => function checkDurationISO860
|
|
|
26
26
|
partName: 'duration',
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
if (!p.
|
|
29
|
+
if (!p.matches('P', false)) {
|
|
30
30
|
return p.unmatched({
|
|
31
31
|
reason: 'unexpected-token',
|
|
32
32
|
expects: [{ type: 'const', value: 'P' }],
|
|
@@ -37,12 +37,12 @@ export const checkDurationISO8601LikeString = () => function checkDurationISO860
|
|
|
37
37
|
if (!d || !d.value) {
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
const [num, sign, extra] = TokenCollection.fromPatterns(d, [
|
|
40
|
+
const [num, sign, extra] = TokenCollection.fromPatterns(d, [/\d+/, /./]);
|
|
41
41
|
if (!num) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
log('Date part: "%s" => %O', d.value, { num, sign });
|
|
45
|
-
if (!num.
|
|
45
|
+
if (!num.matches(/^\d+$/)) {
|
|
46
46
|
return num.unmatched({
|
|
47
47
|
reason: 'unexpected-token',
|
|
48
48
|
expects: [],
|
|
@@ -55,7 +55,7 @@ export const checkDurationISO8601LikeString = () => function checkDurationISO860
|
|
|
55
55
|
partName: 'date',
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
if (!sign.
|
|
58
|
+
if (!sign.matches('D', false)) {
|
|
59
59
|
return sign.unmatched({
|
|
60
60
|
reason: 'unexpected-token',
|
|
61
61
|
expects: [{ type: 'const', value: 'D' }],
|
|
@@ -74,7 +74,7 @@ export const checkDurationISO8601LikeString = () => function checkDurationISO860
|
|
|
74
74
|
expects: [{ type: 'const', value: 'T' }],
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
if (!t.
|
|
77
|
+
if (!t.matches('T', false)) {
|
|
78
78
|
return t.unmatched({
|
|
79
79
|
reason: 'unexpected-token',
|
|
80
80
|
expects: [{ type: 'const', value: 'T' }],
|
|
@@ -93,11 +93,11 @@ export const checkDurationISO8601LikeString = () => function checkDurationISO860
|
|
|
93
93
|
}
|
|
94
94
|
const timeTokens = TokenCollection.fromPatterns(time, [
|
|
95
95
|
// Hour part
|
|
96
|
-
|
|
96
|
+
/\d+(\.\d*)?\D?/,
|
|
97
97
|
// Minute part
|
|
98
|
-
|
|
98
|
+
/\d+(\.\d*)?\D?/,
|
|
99
99
|
// Second part
|
|
100
|
-
|
|
100
|
+
/\d+(\.\d*)?\D?/,
|
|
101
101
|
]);
|
|
102
102
|
log('Time part: "%s" => %O', timeTokens.value, timeTokens);
|
|
103
103
|
const [h, m, s] = timeTokens;
|
|
@@ -120,12 +120,12 @@ export const checkDurationISO8601LikeString = () => function checkDurationISO860
|
|
|
120
120
|
reason: 'extra-token',
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
-
const [num, dpfp, sign] = TokenCollection.fromPatterns(t, [
|
|
123
|
+
const [num, dpfp, sign] = TokenCollection.fromPatterns(t, [/\d+/, /(\.\d*)?/, /\D+/]);
|
|
124
124
|
if (!num) {
|
|
125
125
|
continue;
|
|
126
126
|
}
|
|
127
127
|
log('Time part (h|m|s): "%s" => %O', t.value, { num, dpfp, sign });
|
|
128
|
-
if (!num.
|
|
128
|
+
if (!num.matches(/^\d+$/)) {
|
|
129
129
|
return num.unmatched({
|
|
130
130
|
reason: 'unexpected-token',
|
|
131
131
|
expects: [{ type: 'common', value: 'number' }],
|
|
@@ -133,12 +133,12 @@ export const checkDurationISO8601LikeString = () => function checkDurationISO860
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
if (dpfp && dpfp.value) {
|
|
136
|
-
const [dp, fp] = TokenCollection.fromPatterns(dpfp, [/\./,
|
|
136
|
+
const [dp, fp] = TokenCollection.fromPatterns(dpfp, [/\./, /\d+/]);
|
|
137
137
|
if (!dp) {
|
|
138
138
|
continue;
|
|
139
139
|
}
|
|
140
140
|
log('Second fractional part (h|m|s): "%s" => %O', dpfp.value, { dp, fp });
|
|
141
|
-
if (!dp.
|
|
141
|
+
if (!dp.matches('.')) {
|
|
142
142
|
return dp.unmatched({
|
|
143
143
|
reason: 'unexpected-token',
|
|
144
144
|
expects: [],
|
|
@@ -151,14 +151,14 @@ export const checkDurationISO8601LikeString = () => function checkDurationISO860
|
|
|
151
151
|
partName: 'second',
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
if (!fp.
|
|
154
|
+
if (!fp.matches(/^\d+$/)) {
|
|
155
155
|
return fp.unmatched({
|
|
156
156
|
reason: 'unexpected-token',
|
|
157
157
|
expects: [],
|
|
158
158
|
partName: 'fractional part',
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
if (!(
|
|
161
|
+
if (!(fp.length > 0 && fp.length <= 3)) {
|
|
162
162
|
return fp.unmatched({
|
|
163
163
|
reason: { type: 'out-of-range-length-digit', gte: 1, lte: 3 },
|
|
164
164
|
expects: [],
|
|
@@ -177,16 +177,16 @@ export const checkDurationISO8601LikeString = () => function checkDurationISO860
|
|
|
177
177
|
partName: 'time',
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
|
-
if (specified.has('M') && sign.
|
|
180
|
+
if (specified.has('M') && sign.matches('H', false)) {
|
|
181
181
|
return sign.unmatched({
|
|
182
182
|
reason: 'unexpected-token',
|
|
183
183
|
expects: [{ type: 'const', value: 'S' }],
|
|
184
184
|
partName: 'time',
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
if (!sign.
|
|
188
|
-
(sign.
|
|
189
|
-
(sign.
|
|
187
|
+
if (!sign.matches(['H', 'M', 'S'], false) ||
|
|
188
|
+
(sign.matches('H', false) && specified.has('H')) ||
|
|
189
|
+
(sign.matches('M', false) && specified.has('M'))) {
|
|
190
190
|
return sign.unmatched({
|
|
191
191
|
reason: 'unexpected-token',
|
|
192
192
|
expects: expects.filter(e => !specified.has(e.value)),
|
|
@@ -214,16 +214,16 @@ export const checkDurationComponentListString = () => function checkDurationComp
|
|
|
214
214
|
// 2. One or more ASCII digits, representing a number of time units,
|
|
215
215
|
// scaled by the duration time component scale specified (see below)
|
|
216
216
|
// to represent a number of seconds.
|
|
217
|
-
|
|
217
|
+
/\d+/,
|
|
218
218
|
// 3. If the duration time component scale specified is 1 (i.e. the units are seconds),
|
|
219
219
|
// then, optionally, a U+002E FULL STOP character (.) followed by
|
|
220
220
|
// one, two, or three ASCII digits, representing a fraction of a second.
|
|
221
|
-
/(
|
|
221
|
+
/(\.\d*)?/,
|
|
222
222
|
// 4. Zero or more ASCII whitespace.
|
|
223
223
|
/\s*/,
|
|
224
224
|
// 5. One of the following characters, representing the duration time component scale
|
|
225
225
|
// of the time unit used in the numeric part of the duration time component:
|
|
226
|
-
|
|
226
|
+
/\D/,
|
|
227
227
|
// 6. Zero or more ASCII whitespace.
|
|
228
228
|
/\s*/,
|
|
229
229
|
];
|
|
@@ -232,7 +232,8 @@ export const checkDurationComponentListString = () => function checkDurationComp
|
|
|
232
232
|
const specified = new Set();
|
|
233
233
|
for (const component of components) {
|
|
234
234
|
log('Duration Component: "%s" => %O', component.value, component);
|
|
235
|
-
const
|
|
235
|
+
const dpfp = component[2];
|
|
236
|
+
const unit = component[4];
|
|
236
237
|
const res = component.eachCheck(ws => { }, num => {
|
|
237
238
|
if (!num || !num.value) {
|
|
238
239
|
const reason = dpfp?.value || unit?.value ? 'unexpected-token' : 'missing-token';
|
|
@@ -258,21 +259,21 @@ export const checkDurationComponentListString = () => function checkDurationComp
|
|
|
258
259
|
partName: 'unit',
|
|
259
260
|
});
|
|
260
261
|
}
|
|
261
|
-
const [, fp] = TokenCollection.fromPatterns(dpfp, [/\./,
|
|
262
|
+
const [, fp] = TokenCollection.fromPatterns(dpfp, [/\./, /\d+/]);
|
|
262
263
|
if (!fp || !fp.value) {
|
|
263
264
|
return unmatched('', 'missing-token', {
|
|
264
265
|
expects: [{ type: 'common', value: 'fractional part' }],
|
|
265
266
|
partName: 'fractional part',
|
|
266
267
|
});
|
|
267
268
|
}
|
|
268
|
-
if (!fp.
|
|
269
|
+
if (!fp.matches(/\d+/)) {
|
|
269
270
|
return fp.unmatched({
|
|
270
271
|
reason: 'unexpected-token',
|
|
271
272
|
expects: [{ type: 'common', value: 'fractional part' }],
|
|
272
273
|
partName: 'fractional part',
|
|
273
274
|
});
|
|
274
275
|
}
|
|
275
|
-
if (!(
|
|
276
|
+
if (!(fp.length > 0 && fp.length <= 3)) {
|
|
276
277
|
return fp.unmatched({
|
|
277
278
|
reason: { type: 'out-of-range-length-digit', gte: 1, lte: 3 },
|
|
278
279
|
expects: [],
|
|
@@ -301,14 +302,14 @@ export const checkDurationComponentListString = () => function checkDurationComp
|
|
|
301
302
|
partName: 'unit',
|
|
302
303
|
});
|
|
303
304
|
}
|
|
304
|
-
if (dpfp && dpfp.value && unit.
|
|
305
|
+
if (dpfp && dpfp.value && unit.matches(['w', 'd', 'h', 'm'])) {
|
|
305
306
|
return unit.unmatched({
|
|
306
307
|
reason: 'unexpected-token',
|
|
307
308
|
expects: [{ type: 'const', value: 's' }],
|
|
308
309
|
partName: 'unit',
|
|
309
310
|
});
|
|
310
311
|
}
|
|
311
|
-
if (!unit.
|
|
312
|
+
if (!unit.matches(['w', 'd', 'h', 'm', 's'])) {
|
|
312
313
|
return unit.unmatched({
|
|
313
314
|
reason: 'unexpected-token',
|
|
314
315
|
expects,
|
|
@@ -12,23 +12,23 @@ export const checkGlobalDateAndTimeString = () => function checkGlobalDateAndTim
|
|
|
12
12
|
// YYYY
|
|
13
13
|
/[^-]*/,
|
|
14
14
|
// -
|
|
15
|
-
|
|
15
|
+
/\D?/,
|
|
16
16
|
// MM
|
|
17
17
|
/[^-]*/,
|
|
18
18
|
// -
|
|
19
|
-
|
|
19
|
+
/\D?/,
|
|
20
20
|
// DD
|
|
21
|
-
/[
|
|
21
|
+
/[^\sT]*/,
|
|
22
22
|
// T \s
|
|
23
|
-
|
|
23
|
+
/\D?/,
|
|
24
24
|
// hh
|
|
25
25
|
/[^:]*/,
|
|
26
26
|
// :
|
|
27
|
-
|
|
27
|
+
/\D?/,
|
|
28
28
|
// mm
|
|
29
|
-
/[
|
|
29
|
+
/[^+:Z-]*/,
|
|
30
30
|
// :ss.sss
|
|
31
|
-
/(:[
|
|
31
|
+
/(:[^+Z-]*)?/,
|
|
32
32
|
// time-zone
|
|
33
33
|
/.*/,
|
|
34
34
|
]);
|
|
@@ -37,7 +37,7 @@ export const checkGlobalDateAndTimeString = () => function checkGlobalDateAndTim
|
|
|
37
37
|
if (!second || !second.value) {
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
const secondTokens = TokenCollection.fromPatterns(second, [/:?/,
|
|
40
|
+
const secondTokens = TokenCollection.fromPatterns(second, [/:?/, /\d*/, /\.?/, /\d*/]);
|
|
41
41
|
log('Second Part: "%s" => %O', secondTokens.value, secondTokens);
|
|
42
42
|
const res = secondTokens.eachCheck(datetimeTokenCheck.colon, datetimeTokenCheck.second, datetimeTokenCheck.decimalPointOrEnd, datetimeTokenCheck.secondFractionalPart);
|
|
43
43
|
if (!res.matched) {
|
|
@@ -10,29 +10,29 @@ export const checkLocalDateAndTimeString = () => function checkLocalDateAndTimeS
|
|
|
10
10
|
// YYYY
|
|
11
11
|
/[^-]*/,
|
|
12
12
|
// -
|
|
13
|
-
|
|
13
|
+
/\D?/,
|
|
14
14
|
// MM
|
|
15
15
|
/[^-]*/,
|
|
16
16
|
// -
|
|
17
|
-
|
|
17
|
+
/\D?/,
|
|
18
18
|
// DD
|
|
19
|
-
/[
|
|
19
|
+
/[^\sT]*/,
|
|
20
20
|
// T
|
|
21
|
-
|
|
21
|
+
/\D?/,
|
|
22
22
|
// hh
|
|
23
23
|
/[^:]*/,
|
|
24
24
|
// :
|
|
25
|
-
|
|
25
|
+
/\D?/,
|
|
26
26
|
// mm
|
|
27
27
|
/[^:]*/,
|
|
28
28
|
// :
|
|
29
|
-
|
|
29
|
+
/\D?/,
|
|
30
30
|
// ss
|
|
31
31
|
/[^.]*/,
|
|
32
32
|
// .
|
|
33
|
-
|
|
33
|
+
/\D?/,
|
|
34
34
|
// sss
|
|
35
|
-
|
|
35
|
+
/.\d*/,
|
|
36
36
|
]);
|
|
37
37
|
log('Local Date and Time: "%s" => %O', tokens.value, tokens);
|
|
38
38
|
const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.hyphen, datetimeTokenCheck.month, datetimeTokenCheck.hyphen, datetimeTokenCheck.date, datetimeTokenCheck.localDateTimeSeparator, datetimeTokenCheck.hour, datetimeTokenCheck.colon, datetimeTokenCheck.minute, datetimeTokenCheck.colonOrEnd, datetimeTokenCheck.second, datetimeTokenCheck.decimalPointOrEnd, datetimeTokenCheck.secondFractionalPart, datetimeTokenCheck.extra);
|
|
@@ -50,29 +50,29 @@ export const checkNormalizedLocalDateAndTimeString = () => function checkNormali
|
|
|
50
50
|
// YYYY
|
|
51
51
|
/[^-]*/,
|
|
52
52
|
// -
|
|
53
|
-
|
|
53
|
+
/\D?/,
|
|
54
54
|
// MM
|
|
55
55
|
/[^-]*/,
|
|
56
56
|
// -
|
|
57
|
-
|
|
57
|
+
/\D?/,
|
|
58
58
|
// DD
|
|
59
59
|
/[^T]*/,
|
|
60
60
|
// T
|
|
61
|
-
|
|
61
|
+
/\D?/,
|
|
62
62
|
// hh
|
|
63
63
|
/[^:]*/,
|
|
64
64
|
// :
|
|
65
|
-
|
|
65
|
+
/\D?/,
|
|
66
66
|
// mm
|
|
67
67
|
/[^:]*/,
|
|
68
68
|
// :
|
|
69
|
-
|
|
69
|
+
/\D?/,
|
|
70
70
|
// ss
|
|
71
71
|
/[^.]*/,
|
|
72
72
|
// .
|
|
73
|
-
|
|
73
|
+
/\D?/,
|
|
74
74
|
// sss
|
|
75
|
-
|
|
75
|
+
/.\d*/,
|
|
76
76
|
]);
|
|
77
77
|
log('Normalized Local Date and Time: "%s" => %O', tokens.value, tokens);
|
|
78
78
|
const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.hyphen, datetimeTokenCheck.month, datetimeTokenCheck.hyphen, datetimeTokenCheck.date, datetimeTokenCheck.normalizedlocalDateTimeSeparator, datetimeTokenCheck.hour, datetimeTokenCheck.colon, datetimeTokenCheck.minute, datetimeTokenCheck.colonOrEnd, datetimeTokenCheck.second, datetimeTokenCheck.decimalPointOrEnd, datetimeTokenCheck.secondFractionalPart, datetimeTokenCheck.extra);
|
|
@@ -86,7 +86,8 @@ export const checkNormalizedLocalDateAndTimeString = () => function checkNormali
|
|
|
86
86
|
* > (e.g. omitting the seconds component entirely
|
|
87
87
|
* > if the given time is zero seconds past the minute)
|
|
88
88
|
*/
|
|
89
|
-
const
|
|
89
|
+
const second = tokens[10];
|
|
90
|
+
const fp = tokens[12];
|
|
90
91
|
if (!second || !fp) {
|
|
91
92
|
log('Failed: %O', res);
|
|
92
93
|
return res;
|
|
@@ -6,7 +6,7 @@ import { datetimeTokenCheck } from './datetime-tokens.js';
|
|
|
6
6
|
*/
|
|
7
7
|
export const checkMonthString = () => function checkMonthString(value) {
|
|
8
8
|
log('CHECK: month-string');
|
|
9
|
-
const tokens = TokenCollection.fromPatterns(value, [/[^-]*/,
|
|
9
|
+
const tokens = TokenCollection.fromPatterns(value, [/[^-]*/, /\D?/, /.\d*/]);
|
|
10
10
|
log('Month: "%s" => %O', tokens.value, tokens);
|
|
11
11
|
const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.hyphen, datetimeTokenCheck.month, datetimeTokenCheck.extra);
|
|
12
12
|
if (!res.matched) {
|
|
@@ -10,17 +10,17 @@ export const checkTimeString = () => function checkTimeString(value) {
|
|
|
10
10
|
// hh
|
|
11
11
|
/[^:]*/,
|
|
12
12
|
// :
|
|
13
|
-
|
|
13
|
+
/\D?/,
|
|
14
14
|
// mm
|
|
15
15
|
/[^:]*/,
|
|
16
16
|
// :
|
|
17
|
-
|
|
17
|
+
/\D?/,
|
|
18
18
|
// ss
|
|
19
19
|
/[^.]*/,
|
|
20
20
|
// .
|
|
21
|
-
|
|
21
|
+
/\D?/,
|
|
22
22
|
// sss
|
|
23
|
-
|
|
23
|
+
/.\d*/,
|
|
24
24
|
]);
|
|
25
25
|
log('Time: "%s" => %O', tokens.value, tokens);
|
|
26
26
|
const res = tokens.eachCheck(datetimeTokenCheck.hour, datetimeTokenCheck.colon, datetimeTokenCheck.minute, datetimeTokenCheck.colonOrEnd, datetimeTokenCheck.second, datetimeTokenCheck.decimalPointOrEnd, datetimeTokenCheck.secondFractionalPart);
|
|
@@ -13,13 +13,13 @@ export function parseTimeZone(zone) {
|
|
|
13
13
|
const value = typeof zone === 'string' ? zone : zone.value;
|
|
14
14
|
const zoneTokens = TokenCollection.fromPatterns(zone, [
|
|
15
15
|
// Z + -
|
|
16
|
-
|
|
16
|
+
/\D?/,
|
|
17
17
|
// hh
|
|
18
18
|
/[^:]{0,2}/,
|
|
19
19
|
// :
|
|
20
|
-
|
|
20
|
+
/\D?/,
|
|
21
21
|
// mm
|
|
22
|
-
|
|
22
|
+
/.\d*/,
|
|
23
23
|
]);
|
|
24
24
|
log('Time-zone Part: "%s" => %O', value, zoneTokens);
|
|
25
25
|
const res = zoneTokens.eachCheck((sign, tail) => {
|
|
@@ -33,7 +33,7 @@ export function parseTimeZone(zone) {
|
|
|
33
33
|
partName: 'time-zone',
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
-
if (sign.
|
|
36
|
+
if (sign.matches('Z')) {
|
|
37
37
|
if (tail.value) {
|
|
38
38
|
return (tail[0]?.unmatched({
|
|
39
39
|
reason: 'extra-token',
|
|
@@ -41,7 +41,7 @@ export function parseTimeZone(zone) {
|
|
|
41
41
|
}
|
|
42
42
|
return matched();
|
|
43
43
|
}
|
|
44
|
-
if (!sign.
|
|
44
|
+
if (!sign.matches(['+', '-'])) {
|
|
45
45
|
return sign.unmatched({
|
|
46
46
|
reason: 'unexpected-token',
|
|
47
47
|
expects: [
|
|
@@ -55,7 +55,7 @@ export function parseTimeZone(zone) {
|
|
|
55
55
|
if (!colon || !colon.value) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
if (!colon.
|
|
58
|
+
if (!colon.matches(':')) {
|
|
59
59
|
return colon.unmatched({
|
|
60
60
|
reason: 'unexpected-token',
|
|
61
61
|
expects: [{ type: 'const', value: ':' }],
|
|
@@ -12,9 +12,9 @@ export const checkWeekString = () => function checkWeekString(value) {
|
|
|
12
12
|
// -
|
|
13
13
|
/[^W]?/,
|
|
14
14
|
// W
|
|
15
|
-
|
|
15
|
+
/\D?/,
|
|
16
16
|
// ww
|
|
17
|
-
|
|
17
|
+
/.\d*/,
|
|
18
18
|
]);
|
|
19
19
|
log('Week: "%s" => %O', tokens.value, tokens);
|
|
20
20
|
const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.hyphen, datetimeTokenCheck.weekSign, datetimeTokenCheck.week, datetimeTokenCheck.extra);
|
|
@@ -10,9 +10,9 @@ export const checkYearlessDateString = () => function checkYearlessDateString(va
|
|
|
10
10
|
// MM
|
|
11
11
|
/[^-]*/,
|
|
12
12
|
// -
|
|
13
|
-
|
|
13
|
+
/\D?/,
|
|
14
14
|
// DD
|
|
15
|
-
|
|
15
|
+
/.\d*/,
|
|
16
16
|
]);
|
|
17
17
|
log('Yearless Date: "%s" => %O', tokens.value, tokens);
|
|
18
18
|
const res = tokens.eachCheck(datetimeTokenCheck.month, datetimeTokenCheck.hyphen, datetimeTokenCheck.date, datetimeTokenCheck.extra);
|
package/lib/whatwg/is-abs-url.js
CHANGED
|
@@ -16,14 +16,14 @@ export const isAbsURL = () => {
|
|
|
16
16
|
try {
|
|
17
17
|
new URL(value);
|
|
18
18
|
}
|
|
19
|
-
catch (
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error &&
|
|
21
|
+
typeof error === 'object' &&
|
|
22
|
+
'code' in error && // @ts-ignore
|
|
23
|
+
error.code === 'ERR_INVALID_URL') {
|
|
24
|
+
return false;
|
|
25
25
|
}
|
|
26
|
-
throw
|
|
26
|
+
throw error;
|
|
27
27
|
}
|
|
28
28
|
return true;
|
|
29
29
|
};
|
|
@@ -7,5 +7,7 @@ import type { FormattedPrimitiveTypeCreator } from '../types.js';
|
|
|
7
7
|
* > that does not start with a U+005F LOW LINE character.
|
|
8
8
|
* > (Names starting with an underscore are reserved for special keywords.)
|
|
9
9
|
*
|
|
10
|
+
* @deprecated
|
|
11
|
+
*
|
|
10
12
|
*/
|
|
11
13
|
export declare const isBrowserContextName: FormattedPrimitiveTypeCreator;
|
|
@@ -2,7 +2,14 @@ import type { FormattedPrimitiveTypeCreator } from '../types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* valid name of custom element
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* > PotentialCustomElementName ::=
|
|
6
|
+
* > [a-z] (PCENChar)* '-' (PCENChar)*
|
|
7
|
+
* > PCENChar ::=
|
|
8
|
+
* > "-" | "." | [0-9] | "_" | [a-z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
|
|
9
|
+
* > [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
10
|
+
* > This uses the EBNF notation from the XML specification. [XML]
|
|
11
|
+
*
|
|
12
|
+
* > They start with an ASCII lower alpha, ensuring that the HTML parser will treat them as tags instead of as text.
|
|
6
13
|
*
|
|
7
14
|
* > - name must match the [PotentialCustomElementName](https://html.spec.whatwg.org/multipage/custom-elements.html#prod-potentialcustomelementname) production
|
|
8
15
|
* > - name must not be any of the following:
|
|
@@ -15,8 +22,6 @@ import type { FormattedPrimitiveTypeCreator } from '../types.js';
|
|
|
15
22
|
* > - `<font-face-name>`
|
|
16
23
|
* > - `<missing-glyph>`
|
|
17
24
|
*
|
|
18
|
-
*
|
|
19
|
-
* Originally, it is not possible to define a name including ASCII upper alphas in the custom element, but it is not treated as illegal by the HTML parser.
|
|
20
|
-
*
|
|
25
|
+
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
|
|
21
26
|
*/
|
|
22
27
|
export declare const isCustomElementName: FormattedPrimitiveTypeCreator;
|