1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | exports.htmlSelectorFormat = void 0;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | const unicodeRanges = [
|
16 | [0xc0, 0xd6],
|
17 | [0xd8, 0xf6],
|
18 | [0xf8, 0x37d],
|
19 | [0x37f, 0x1fff],
|
20 | [0x200c, 0x200d],
|
21 | [0x203f, 0x2040],
|
22 | [0x2070, 0x218f],
|
23 | [0x2c00, 0x2fef],
|
24 | [0x3001, 0xd7ff],
|
25 | [0xf900, 0xfdcf],
|
26 | [0xfdf0, 0xfffd],
|
27 | [0x10000, 0xeffff],
|
28 | ];
|
29 | function isValidElementName(name) {
|
30 | let regex = '^[a-zA-Z][';
|
31 | regex += '-.0-9_a-zA-Z\\u{B7}';
|
32 | for (const range of unicodeRanges) {
|
33 | regex += `\\u{${range[0].toString(16)}}-\\u{${range[1].toString(16)}}`;
|
34 | }
|
35 | regex += ']*$';
|
36 | return new RegExp(regex, 'u').test(name);
|
37 | }
|
38 | exports.htmlSelectorFormat = {
|
39 | name: 'html-selector',
|
40 | formatter: {
|
41 | async: false,
|
42 | validate: (name) => typeof name === 'string' && isValidElementName(name),
|
43 | },
|
44 | };
|