diff options
author | 2021-04-01 10:25:28 -0600 | |
---|---|---|
committer | 2021-04-01 10:25:28 -0600 | |
commit | c26c244ca2634d462616d6cf71072fbe26becba2 (patch) | |
tree | 1bd5e83eff9ca88200aacb272c84439f192015ec /src/parser/utils/names.ts | |
parent | f6a7ac67befff863e34133673efb78ea7ac0fe48 (diff) | |
download | astro-c26c244ca2634d462616d6cf71072fbe26becba2.tar.gz astro-c26c244ca2634d462616d6cf71072fbe26becba2.tar.zst astro-c26c244ca2634d462616d6cf71072fbe26becba2.zip |
Annoying Lint PR #2 (#47)
Diffstat (limited to '')
-rw-r--r-- | src/parser/utils/names.ts | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/parser/utils/names.ts b/src/parser/utils/names.ts index f2e1dfc8e..f041d20ce 100644 --- a/src/parser/utils/names.ts +++ b/src/parser/utils/names.ts @@ -113,10 +113,12 @@ export const reserved = new Set([ const void_element_names = /^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/; +/** Is this a void HTML element? */ export function is_void(name: string) { return void_element_names.test(name) || name.toLowerCase() === '!doctype'; } +/** Is this a valid HTML element? */ export function is_valid(str: string): boolean { let i = 0; @@ -130,6 +132,7 @@ export function is_valid(str: string): boolean { return true; } +/** Utility to normalize HTML */ export function sanitize(name: string) { return name .replace(/[^a-zA-Z0-9_]+/g, '_') |