From 6d7bb2e21ae99e174e279cb0ad36554c485fc8d4 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Sat, 21 Sep 2024 19:54:50 -0500 Subject: [PATCH 1/2] refactor: Switch `HTML_LOWER_CASE` rgx to always match from line start --- src/lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/util.js b/src/lib/util.js index 84b348d..c5f7158 100644 --- a/src/lib/util.js +++ b/src/lib/util.js @@ -1,7 +1,7 @@ export const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/; 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_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 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 From 6db4f95ab3fc303b754765c11e64a72d9583d87b Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Sat, 21 Sep 2024 19:58:36 -0500 Subject: [PATCH 2/2] docs: Add changeset --- .changeset/kind-pumas-wash.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/kind-pumas-wash.md diff --git a/.changeset/kind-pumas-wash.md b/.changeset/kind-pumas-wash.md new file mode 100644 index 0000000..874940a --- /dev/null +++ b/.changeset/kind-pumas-wash.md @@ -0,0 +1,5 @@ +--- +'preact-render-to-string': patch +--- + +Switch `HTML_LOWER_CASE` regex to match all from line start for a marginal perf benefit.