@xaendar/common 0.5.6 → 0.5.8
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.
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indents each line of a code block by two spaces.
|
|
3
|
+
* @param lines The lines of code to indent.
|
|
4
|
+
* @return An array of indented lines.
|
|
5
|
+
*/
|
|
6
|
+
export declare function indent(...lines: string[]): string[];
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Asserts that a given tag name is valid for use as a custom element name.
|
|
3
10
|
* A valid custom element name must:
|
|
@@ -11,14 +18,7 @@
|
|
|
11
18
|
* @param tagName The tag name to validate.
|
|
12
19
|
* @throws Will throw an error if the tag name is invalid.
|
|
13
20
|
*/
|
|
14
|
-
export declare function
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Indents each line of a code block by two spaces.
|
|
18
|
-
* @param lines The lines of code to indent.
|
|
19
|
-
* @return An array of indented lines.
|
|
20
|
-
*/
|
|
21
|
-
export declare function indent(...lines: string[]): string[];
|
|
21
|
+
export declare function isValidCustomElementName(tagName: string): boolean;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* A generic LIFO (Last In, First Out) stack data structure.
|
|
@@ -84,14 +84,14 @@ var NOT_ALLOWED_TAGS = [
|
|
|
84
84
|
* @param tagName The tag name to validate.
|
|
85
85
|
* @throws Will throw an error if the tag name is invalid.
|
|
86
86
|
*/
|
|
87
|
-
function
|
|
87
|
+
function isValidCustomElementName(tagName) {
|
|
88
88
|
if (!/^[a-z][a-z0-9._\-]*-[a-z0-9._\-]*$/.test(tagName)) {
|
|
89
89
|
console.error(`Tag <${tagName}> is not a valid custom element name. Custom element names must:
|
|
90
90
|
- contain a hyphen
|
|
91
91
|
- no spaces.
|
|
92
92
|
- start with a lowercase letter.
|
|
93
93
|
- not contain uppercase letters.
|
|
94
|
-
- not
|
|
94
|
+
- not be a native HTML tag name.
|
|
95
95
|
- not contain the following chars: '@', '#', '$', '%', '&', '*', '!', '?', '/', '\\', '|', "'", '"', '<', '>', '='
|
|
96
96
|
`);
|
|
97
97
|
return false;
|
|
@@ -117,4 +117,4 @@ function isReservedTagName(tagName) {
|
|
|
117
117
|
return NOT_ALLOWED_TAGS.includes(tagName);
|
|
118
118
|
}
|
|
119
119
|
//#endregion
|
|
120
|
-
export { Stack,
|
|
120
|
+
export { Stack, indent, isValidCustomElementName };
|