@staticbolt/core 1.0.0-beta.6 → 1.0.0-beta.7

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.
@@ -5105,7 +5105,10 @@ function parseHtmlSources(ast) {
5105
5105
  //#endregion
5106
5106
  //#region src/parsers/html-parser.ts
5107
5107
  function parseHtmlUnsafe(html, options = {}) {
5108
- return parse(html, options);
5108
+ return parse(html, {
5109
+ comment: true,
5110
+ ...options
5111
+ });
5109
5112
  }
5110
5113
  /** Parse HTML string and return the root node */
5111
5114
  const parseHtml = valueOrError(parseHtmlUnsafe);
@@ -5208,24 +5211,25 @@ function coreHtmlPlugin(options = {}) {
5208
5211
  const nodeIdMap = /* @__PURE__ */ new Map();
5209
5212
  const scriptsAndStyles = metadata.ast.querySelectorAll("script,style");
5210
5213
  for (const node of scriptsAndStyles) {
5211
- const minifyTag = minify || node.hasAttribute(minifyAttribute);
5212
- node.removeAttribute(minifyAttribute);
5213
- const id = node.getAttribute(CUSTOM_ATTRIBUTES.MetadataID);
5214
- if (!id) continue;
5215
- nodeIdMap.set(node, id);
5216
- node.removeAttribute(CUSTOM_ATTRIBUTES.MetadataID);
5214
+ const hasMinifyAttribute = node.hasAttribute(minifyAttribute);
5215
+ const shouldMinify = minify || hasMinifyAttribute;
5217
5216
  const isScript = node.tagName === "SCRIPT";
5217
+ node.removeAttribute(minifyAttribute);
5218
5218
  const scriptType = node.getAttribute("type");
5219
5219
  if (isScript && !isScriptType(scriptType)) continue;
5220
- const tagMetadata = metadata[isScript ? "scriptsMetadataList" : "stylesMetadataList"].get(id);
5220
+ const metadataID = node.getAttribute(CUSTOM_ATTRIBUTES.MetadataID);
5221
+ if (!metadataID) continue;
5222
+ nodeIdMap.set(node, metadataID);
5223
+ node.removeAttribute(CUSTOM_ATTRIBUTES.MetadataID);
5224
+ const tagMetadata = metadata[isScript ? "scriptsMetadataList" : "stylesMetadataList"].get(metadataID);
5221
5225
  if (!tagMetadata) continue;
5222
5226
  const code = await this.stringify(tagMetadata, {
5223
- format: format && !minifyTag,
5224
- minify: minifyTag
5227
+ format: format && !shouldMinify,
5228
+ minify: shouldMinify
5225
5229
  });
5226
5230
  if (!code) continue;
5227
5231
  node.textContent = code;
5228
- if (format && minifyTag) node.replaceWith(ignoreFormatComment + node.outerHTML);
5232
+ if (format && hasMinifyAttribute) node.replaceWith(ignoreFormatComment + node.outerHTML);
5229
5233
  }
5230
5234
  const code = metadata.ast.toString();
5231
5235
  for (const [node, metadataID] of nodeIdMap) node.setAttribute(CUSTOM_ATTRIBUTES.MetadataID, metadataID);