@coherent.js/core 1.0.1 → 1.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/dist/index.js CHANGED
@@ -604,9 +604,21 @@ function formatAttributes(props) {
604
604
  }
605
605
  return formatted.trim();
606
606
  }
607
+ function stripComments(html) {
608
+ let out = "";
609
+ let cursor = 0;
610
+ for (; ; ) {
611
+ const start = html.indexOf("<!--", cursor);
612
+ if (start === -1) return out + html.slice(cursor);
613
+ out += html.slice(cursor, start);
614
+ const end = html.indexOf("-->", start + 4);
615
+ if (end === -1) return out;
616
+ cursor = end + 3;
617
+ }
618
+ }
607
619
  function minifyHtml(html, options = {}) {
608
620
  if (!options.minify) return html;
609
- return html.replace(/<!--[\s\S]*?-->/g, "").replace(/\s+/g, " ").replace(/>\s+</g, "><").trim();
621
+ return stripComments(html).replace(/\s+/g, " ").replace(/>\s+</g, "><").trim();
610
622
  }
611
623
 
612
624
  // src/core/object-utils.js
@@ -4914,7 +4926,8 @@ function renderComponentContent(obj) {
4914
4926
  if (value === true) return attrName;
4915
4927
  return `${attrName}="${escapeHTML(String(value))}"`;
4916
4928
  }).join(" ");
4917
- const openTag = attrsStr ? `<${tagName} ${attrsStr}>` : `<${tagName}>`;
4929
+ const attrsPart = attrsStr ? ` ${attrsStr}` : "";
4930
+ const openTag = `<${tagName}${attrsPart}>`;
4918
4931
  if ([
4919
4932
  "area",
4920
4933
  "base",
@@ -4931,7 +4944,7 @@ function renderComponentContent(obj) {
4931
4944
  "track",
4932
4945
  "wbr"
4933
4946
  ].includes(tagName)) {
4934
- return openTag.replace(">", " />");
4947
+ return `<${tagName}${attrsPart} />`;
4935
4948
  }
4936
4949
  let content = "";
4937
4950
  if (text !== void 0) {
@@ -6517,7 +6530,7 @@ function deepClone2(obj) {
6517
6530
  }
6518
6531
  return cloned;
6519
6532
  }
6520
- var VERSION = true ? "1.0.1" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
6533
+ var VERSION = true ? "1.1.2" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
6521
6534
  var fp = {
6522
6535
  /**
6523
6536
  * Curried map: fp.map(fn)(array)