jq79 0.4.7 → 0.4.9

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": "jq79",
3
- "version": "0.4.7",
3
+ "version": "0.4.9",
4
4
  "description": "Mini reactive component library: single-file components, Svelte-style setup scripts, fine-grained proxy reactivity. Single-file build, zero dependencies.",
5
5
  "keywords": [
6
6
  "reactive",
package/src/dom.ts CHANGED
@@ -173,10 +173,16 @@ function sanitizeNode(node: HTMLElement, depth: number, allowUrl?: AllowUrl): HT
173
173
  }
174
174
 
175
175
  export function sanitizeHTML(html: string, options?: SanitizeOptions): string {
176
- const doc = new DOMParser().parseFromString(html, 'text/html');
176
+ // parsear con <template> en vez de con DOMParser: el contenido de un template
177
+ // es un documento inerte igual (ni scripts ni imágenes se ejecutan al asignar
178
+ // innerHTML), pero el parseo de fragmento conserva el espacio en blanco inicial
179
+ // que el modo "before body" de un documento completo descartaría - así una
180
+ // primera línea indentada (un diff, un <pre>) llega con su sangría intacta
181
+ const template = document.createElement('template');
182
+ template.innerHTML = html;
177
183
  const container = document.createElement('div');
178
184
 
179
- appendSanitizedChildren(doc.body, container, 0, options?.allowUrl);
185
+ appendSanitizedChildren(template.content, container, 0, options?.allowUrl);
180
186
 
181
187
  return container.innerHTML;
182
188
  }