mnfst-render 0.2.5 → 0.2.6

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.
@@ -1390,10 +1390,13 @@ async function runPrerender(config) {
1390
1390
  const first = tpl.content?.firstElementChild;
1391
1391
  if (first) {
1392
1392
  const tag = first.tagName;
1393
+ const cls = first.getAttribute('class') || '';
1393
1394
  let next = tpl.nextElementSibling;
1394
1395
  let generatedCount = 0;
1395
1396
  while (next) {
1396
1397
  if (next.tagName !== tag) break;
1398
+ const sameClass = (next.getAttribute('class') || '') === cls;
1399
+ if (!sameClass) break;
1397
1400
  generatedCount++;
1398
1401
  next = next.nextElementSibling;
1399
1402
  }
@@ -1491,7 +1494,35 @@ async function runPrerender(config) {
1491
1494
  if (!bindingAttrRegex.test(attr.name)) continue;
1492
1495
  const expr = attr.value || '';
1493
1496
  if (hasVar(expr, itemVar) || hasVar(expr, indexVar)) {
1494
- node.removeAttribute(attr.name);
1497
+ const name = attr.name;
1498
+ // Remove text/html bindings only when static content already exists.
1499
+ if (name === 'x-text' || name === 'x-html') {
1500
+ if ((node.textContent || '').trim() || (node.innerHTML || '').trim()) {
1501
+ node.removeAttribute(name);
1502
+ }
1503
+ continue;
1504
+ }
1505
+
1506
+ // Remove x-show/x-if if they reference loop vars; cloned node is now static.
1507
+ if (name === 'x-show' || name === 'x-if') {
1508
+ node.removeAttribute(name);
1509
+ continue;
1510
+ }
1511
+
1512
+ // For :attr / x-bind:attr, only remove binding if a concrete attr is present.
1513
+ let boundAttr = '';
1514
+ if (name.startsWith(':')) boundAttr = name.slice(1);
1515
+ else if (name.startsWith('x-bind:')) boundAttr = name.slice('x-bind:'.length);
1516
+ if (boundAttr) {
1517
+ const concrete = node.getAttribute(boundAttr);
1518
+ if (concrete != null && String(concrete).trim() !== '') {
1519
+ node.removeAttribute(name);
1520
+ }
1521
+ continue;
1522
+ }
1523
+
1524
+ // Event/other loop-scoped bindings are unsafe on static clones.
1525
+ node.removeAttribute(name);
1495
1526
  }
1496
1527
  }
1497
1528
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst-render",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Render Manifest sites to static HTML for SEO",
5
5
  "type": "module",
6
6
  "bin": {