@vojtaholik/static-kit-core 2.1.11 → 2.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vojtaholik/static-kit-core",
3
- "version": "2.1.11",
3
+ "version": "2.1.13",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -166,6 +166,11 @@ export async function renderPage(
166
166
  data: `__REGION_CONTENT_${regionName}__`,
167
167
  } as Node,
168
168
  ];
169
+
170
+ // Strip data-region in production
171
+ if (!options.isDev) {
172
+ removeAttr(node, "data-region");
173
+ }
169
174
  }
170
175
  }
171
176
  });
@@ -293,6 +298,13 @@ function setAttr(node: Node, name: string, value: string): void {
293
298
  }
294
299
  }
295
300
 
301
+ function removeAttr(node: Node, name: string): void {
302
+ const element = node as Element;
303
+ if (element.attrs) {
304
+ element.attrs = element.attrs.filter((a) => a.name !== name);
305
+ }
306
+ }
307
+
296
308
  /**
297
309
  * Strip dev-only attributes (data-block-id, data-schema-address) from production HTML
298
310
  */
@@ -255,9 +255,10 @@ function compileElement(element: Element, indent: number): string {
255
255
  continue;
256
256
  }
257
257
  // Conditionally render attribute only if value is truthy
258
- code += `${pad}const _${attrName}Val = ${attr.value};\n`;
259
- code += `${pad}if (_${attrName}Val) {\n`;
260
- code += `${pad} out += " ${attrName}=\\"" + escapeAttr(_${attrName}Val) + "\\"";\n`;
258
+ const varName = attrName.replace(/[^a-zA-Z0-9_]/g, "_");
259
+ code += `${pad}const _${varName}Val = ${attr.value};\n`;
260
+ code += `${pad}if (_${varName}Val) {\n`;
261
+ code += `${pad} out += " ${attrName}=\\"" + escapeAttr(_${varName}Val) + "\\"";\n`;
261
262
  code += `${pad}}\n`;
262
263
  }
263
264
  }