@xaendar/common 0.5.4 → 0.5.5
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/dist/xaendar-common.es.d.ts +1 -1
- package/dist/xaendar-common.es.js +13 -123
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @param tagName The tag name to validate.
|
|
12
12
|
* @throws Will throw an error if the tag name is invalid.
|
|
13
13
|
*/
|
|
14
|
-
export declare function assertIsValidElementName(tagName: string):
|
|
14
|
+
export declare function assertIsValidElementName(tagName: string): boolean;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Indents each line of a code block by two spaces.
|
|
@@ -55,114 +55,6 @@ function indent(...lines) {
|
|
|
55
55
|
return lines.map((line) => ` ${line}`);
|
|
56
56
|
}
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region ../packages/common/src/costants/base-tags.constants.ts
|
|
59
|
-
/**
|
|
60
|
-
* List of all standard, valid HTML tags in Xaendar Components's Template
|
|
61
|
-
*
|
|
62
|
-
* These are native HTML elements and should not be used as custom element names.
|
|
63
|
-
*/
|
|
64
|
-
var HTML_TAGS = [
|
|
65
|
-
"section",
|
|
66
|
-
"article",
|
|
67
|
-
"aside",
|
|
68
|
-
"nav",
|
|
69
|
-
"header",
|
|
70
|
-
"footer",
|
|
71
|
-
"address",
|
|
72
|
-
"h1",
|
|
73
|
-
"h2",
|
|
74
|
-
"h3",
|
|
75
|
-
"h4",
|
|
76
|
-
"h5",
|
|
77
|
-
"h6",
|
|
78
|
-
"p",
|
|
79
|
-
"hr",
|
|
80
|
-
"pre",
|
|
81
|
-
"blockquote",
|
|
82
|
-
"ol",
|
|
83
|
-
"ul",
|
|
84
|
-
"li",
|
|
85
|
-
"dl",
|
|
86
|
-
"dt",
|
|
87
|
-
"dd",
|
|
88
|
-
"figure",
|
|
89
|
-
"figcaption",
|
|
90
|
-
"div",
|
|
91
|
-
"a",
|
|
92
|
-
"span",
|
|
93
|
-
"br",
|
|
94
|
-
"wbr",
|
|
95
|
-
"b",
|
|
96
|
-
"strong",
|
|
97
|
-
"i",
|
|
98
|
-
"em",
|
|
99
|
-
"u",
|
|
100
|
-
"s",
|
|
101
|
-
"mark",
|
|
102
|
-
"small",
|
|
103
|
-
"sub",
|
|
104
|
-
"sup",
|
|
105
|
-
"abbr",
|
|
106
|
-
"cite",
|
|
107
|
-
"code",
|
|
108
|
-
"var",
|
|
109
|
-
"kbd",
|
|
110
|
-
"samp",
|
|
111
|
-
"time",
|
|
112
|
-
"data",
|
|
113
|
-
"dfn",
|
|
114
|
-
"q",
|
|
115
|
-
"ruby",
|
|
116
|
-
"rt",
|
|
117
|
-
"rp",
|
|
118
|
-
"bdi",
|
|
119
|
-
"bdo",
|
|
120
|
-
"ins",
|
|
121
|
-
"del",
|
|
122
|
-
"img",
|
|
123
|
-
"iframe",
|
|
124
|
-
"embed",
|
|
125
|
-
"object",
|
|
126
|
-
"param",
|
|
127
|
-
"picture",
|
|
128
|
-
"source",
|
|
129
|
-
"track",
|
|
130
|
-
"video",
|
|
131
|
-
"audio",
|
|
132
|
-
"map",
|
|
133
|
-
"area",
|
|
134
|
-
"table",
|
|
135
|
-
"caption",
|
|
136
|
-
"colgroup",
|
|
137
|
-
"col",
|
|
138
|
-
"tbody",
|
|
139
|
-
"thead",
|
|
140
|
-
"tfoot",
|
|
141
|
-
"tr",
|
|
142
|
-
"td",
|
|
143
|
-
"th",
|
|
144
|
-
"form",
|
|
145
|
-
"label",
|
|
146
|
-
"input",
|
|
147
|
-
"button",
|
|
148
|
-
"select",
|
|
149
|
-
"datalist",
|
|
150
|
-
"optgroup",
|
|
151
|
-
"option",
|
|
152
|
-
"textarea",
|
|
153
|
-
"output",
|
|
154
|
-
"progress",
|
|
155
|
-
"meter",
|
|
156
|
-
"fieldset",
|
|
157
|
-
"legend",
|
|
158
|
-
"details",
|
|
159
|
-
"summary",
|
|
160
|
-
"dialog",
|
|
161
|
-
"template",
|
|
162
|
-
"slot",
|
|
163
|
-
"canvas"
|
|
164
|
-
];
|
|
165
|
-
//#endregion
|
|
166
58
|
//#region ../packages/common/src/costants/not-alllowed-tags.constants.ts
|
|
167
59
|
/**
|
|
168
60
|
* List of strings not allowed as names for CustomElements
|
|
@@ -193,26 +85,24 @@ var NOT_ALLOWED_TAGS = [
|
|
|
193
85
|
* @throws Will throw an error if the tag name is invalid.
|
|
194
86
|
*/
|
|
195
87
|
function assertIsValidElementName(tagName) {
|
|
196
|
-
if (!/^[a-z][a-z0-9._\-]*-[a-z0-9._\-]*$/.test(tagName))
|
|
88
|
+
if (!/^[a-z][a-z0-9._\-]*-[a-z0-9._\-]*$/.test(tagName)) {
|
|
89
|
+
console.error(`Tag <${tagName}> is not a valid custom element name. Custom element names must:
|
|
197
90
|
- contain a hyphen
|
|
198
|
-
- no spaces.
|
|
199
|
-
- start with a lowercase letter.
|
|
200
|
-
- not contain uppercase letters.
|
|
91
|
+
- no spaces.
|
|
92
|
+
- start with a lowercase letter.
|
|
93
|
+
- not contain uppercase letters.
|
|
94
|
+
- not to be a native HTML tag name.
|
|
201
95
|
- not contain the following chars: '@', '#', '$', '%', '&', '*', '!', '?', '/', '\\', '|', "'", '"', '<', '>', '='
|
|
202
96
|
`);
|
|
203
|
-
|
|
204
|
-
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (isReservedTagName(tagName)) {
|
|
100
|
+
console.error(`Tag <${tagName}> is a reserved tag name and cannot be used as a custom element name.
|
|
205
101
|
Reserved names are:
|
|
206
102
|
- ${NOT_ALLOWED_TAGS.join("\n- ")}`);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
*
|
|
211
|
-
* @param tagName - The tag name to check.
|
|
212
|
-
* @returns `true` if the tag name is a standard HTML tag, `false` otherwise.
|
|
213
|
-
*/
|
|
214
|
-
function isNativeHTMLTag(tagName) {
|
|
215
|
-
return HTML_TAGS.includes(tagName);
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
216
106
|
}
|
|
217
107
|
/**
|
|
218
108
|
* Checks if a tag name is reserved and cannot be used for a custom element.
|