@pracht/preact-ssr-precompile 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -101,8 +101,8 @@ SSR semantics, including:
101
101
  - `textarea`, `select`, and `option`.
102
102
 
103
103
  Dynamic children are wrapped in `jsxEscape()`. Dynamic attributes are serialized
104
- with `jsxAttr()`, with extra handling for ARIA and enumerated boolean attributes
105
- so output matches `preact-render-to-string`.
104
+ with `jsxAttr()`, with extra handling for `aria-*`, `data-*`, and enumerated
105
+ boolean attributes so output matches `preact-render-to-string`.
106
106
 
107
107
  ## Options
108
108
 
package/dist/index.mjs CHANGED
@@ -305,7 +305,7 @@ var TransformContext = class {
305
305
  }
306
306
  appendStaticAttribute(strings, attrName, value) {
307
307
  if (value == null) return;
308
- if (isAriaOrEnumerated(attrName) && typeof value === "boolean") {
308
+ if (isStringifiedBooleanAttr(attrName) && typeof value === "boolean") {
309
309
  strings[strings.length - 1] += ` ${encodeEntities(attrName)}=${JSON.stringify(String(value))}`;
310
310
  return;
311
311
  }
@@ -319,7 +319,7 @@ var TransformContext = class {
319
319
  jsxAttrCall(attrName, expression) {
320
320
  const serializedName = JSON.stringify(attrName);
321
321
  this.usedHelpers.add("jsxAttr");
322
- return `((attr) => attr ? " " + attr : "")(${isAriaOrEnumerated(attrName) ? `((value) => typeof value === "boolean" ? ${this.jsxAttrIdent}(${serializedName}, String(value)) : ${this.jsxAttrIdent}(${serializedName}, value))(${expression})` : `${this.jsxAttrIdent}(${serializedName}, ${expression})`})`;
322
+ return `((attr) => attr ? " " + attr : "")(${isStringifiedBooleanAttr(attrName) ? `((value) => typeof value === "boolean" ? ${this.jsxAttrIdent}(${serializedName}, String(value)) : ${this.jsxAttrIdent}(${serializedName}, value))(${expression})` : `${this.jsxAttrIdent}(${serializedName}, ${expression})`})`;
323
323
  }
324
324
  genTemplate(strings, dynamics) {
325
325
  const templateName = uniqueName(`$$_tpl_${++this.templateIndex}`, this.takenNames);
@@ -438,8 +438,8 @@ function encodeEntities(value) {
438
438
  if (last !== value.length) out += value.slice(last);
439
439
  return out;
440
440
  }
441
- function isAriaOrEnumerated(name) {
442
- return name.startsWith("aria-") || HTML_ENUMERATED_ATTRS.has(name);
441
+ function isStringifiedBooleanAttr(name) {
442
+ return name.charCodeAt(4) === 45 || HTML_ENUMERATED_ATTRS.has(name);
443
443
  }
444
444
  function insertPrelude(s, program, prelude) {
445
445
  if (prelude.trim() === "") return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pracht/preact-ssr-precompile",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Experimental Vite/Rolldown plugin that precompiles safe Preact JSX for faster server-side rendering.",
5
5
  "keywords": [
6
6
  "pracht",