Skip to content

Commit 6255591

Browse files
committed
refactor: Switch to a Set
1 parent 62ade27 commit 6255591

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ function _renderToString(
625625
} else if (UNSAFE_NAME.test(name)) {
626626
continue;
627627
} else if (
628-
(name[4] === '-' || HTML_ENUMERATED.test(name)) &&
628+
(name[4] === '-' || HTML_ENUMERATED.has(name)) &&
629629
v != null
630630
) {
631631
// serialize boolean aria-xyz or enumerated attribute values as strings

src/lib/util.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ export const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|
22
export const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
33
export const NAMESPACE_REPLACE_REGEX = /^(xlink|xmlns|xml)([A-Z])/;
44
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]/;
5-
export const HTML_ENUMERATED = /^dra|spel/;
65
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/;
76

7+
// Boolean DOM properties that translate to enumerated ('true'/'false') attributes
8+
export const HTML_ENUMERATED = new Set(['draggable', 'spellcheck']);
9+
810
// DOM properties that should NOT have "px" added when numeric
911
const ENCODED_ENTITIES = /["&<]/;
1012

0 commit comments

Comments
 (0)