Skip to content

Commit 8e49cc2

Browse files
committed
refactor: Switch HTML_LOWER_CASE over
1 parent bfb7d3f commit 8e49cc2

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ function _renderToString(
637637
? 'panose-1'
638638
: name.replace(/([A-Z])/g, '-$1').toLowerCase();
639639
}
640-
} else if (HTML_LOWER_CASE.test(name)) {
640+
} else if (HTML_LOWER_CASE.has(name)) {
641641
name = name.toLowerCase();
642642
}
643643
}

src/lib/util.js

+47-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,53 @@ export const VOID_ELEMENTS = new Set([
1818
]);
1919
export const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
2020
export const NAMESPACE_REPLACE_REGEX = /^(xlink|xmlns|xml)([A-Z])/;
21-
export const HTML_LOWER_CASE = /^accessK|^auto[A-Z]|^cell|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|src[A-Z]|tabI|useM|item[A-Z]/;
21+
22+
export const HTML_LOWER_CASE = new Set([
23+
'accessKey',
24+
'accessKeyLabel',
25+
'autoComplete',
26+
'autoCorrect',
27+
'autoFocus',
28+
'autoPlay',
29+
'autoCapitalize',
30+
'cellPadding',
31+
'cellSpacing',
32+
'charSet',
33+
'colSpan',
34+
'contentEditable',
35+
'contextMenu',
36+
'controlsList',
37+
'crossOrigin',
38+
'dateTime',
39+
'encType',
40+
'formAction',
41+
'formEncType',
42+
'formMethod',
43+
'formNoValidate',
44+
'formTarget',
45+
'frameBorder',
46+
'hrefLang',
47+
'inputMode',
48+
'maxLength',
49+
'minLength',
50+
'noValidate',
51+
'playsInline',
52+
'popoverTarget',
53+
'popoverTargetAction',
54+
'readOnly',
55+
'rowSpan',
56+
'srcSet',
57+
'srcDoc',
58+
'srcLang',
59+
'tabIndex',
60+
'useMap',
61+
'itemProp',
62+
'itemScope',
63+
'itemType',
64+
'itemID',
65+
'itemRef'
66+
]);
67+
2268
export const SVG_CAMEL_CASE = /^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/;
2369

2470
// Boolean DOM properties that translate to enumerated ('true'/'false') attributes

src/pretty.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ function _renderToStringPretty(
258258
? 'panose-1'
259259
: name.replace(/([A-Z])/g, '-$1').toLowerCase();
260260
}
261-
} else if (HTML_LOWER_CASE.test(name)) {
261+
} else if (HTML_LOWER_CASE.has(name)) {
262262
name = name.toLowerCase();
263263
}
264264

0 commit comments

Comments
 (0)