Skip to content

Commit

Permalink
refactor: Switch to a Set
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Sep 14, 2024
1 parent 62ade27 commit 6255591
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ function _renderToString(
} else if (UNSAFE_NAME.test(name)) {
continue;
} else if (
(name[4] === '-' || HTML_ENUMERATED.test(name)) &&
(name[4] === '-' || HTML_ENUMERATED.has(name)) &&
v != null
) {
// serialize boolean aria-xyz or enumerated attribute values as strings
Expand Down
4 changes: 3 additions & 1 deletion src/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ export const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|
export const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
export const NAMESPACE_REPLACE_REGEX = /^(xlink|xmlns|xml)([A-Z])/;
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]/;
export const HTML_ENUMERATED = /^dra|spel/;
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/;

// Boolean DOM properties that translate to enumerated ('true'/'false') attributes
export const HTML_ENUMERATED = new Set(['draggable', 'spellcheck']);

// DOM properties that should NOT have "px" added when numeric
const ENCODED_ENTITIES = /["&<]/;

Expand Down

0 comments on commit 6255591

Please sign in to comment.