jq79 0.3.20 → 0.3.22

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/src/dom.ts CHANGED
@@ -1,16 +1,25 @@
1
1
  // DOM helpers: tiny query/create utilities, also injected into component
2
2
  // scripts as $, $$ and $create
3
3
 
4
- export const $ = (selectorOrEl: string | Element, selector?: string) =>
5
- typeof selectorOrEl === "string"
4
+ // $(selector) queries the document; $(el, selector) queries within el. The
5
+ // selector is required in the element form - an empty one is a SyntaxError
6
+ export function $(selector: string): Element | null
7
+ export function $(el: Element, selector: string): Element | null
8
+ export function $(selectorOrEl: string | Element, selector?: string): Element | null {
9
+ return typeof selectorOrEl === "string"
6
10
  ? document.querySelector(selectorOrEl)
7
- : selectorOrEl.querySelector(selector || "")
11
+ : selectorOrEl.querySelector(selector!)
12
+ }
8
13
 
9
- export const $$ = (selectorOrEl: string | Element, selector?: string) => Array.from(
10
- typeof selectorOrEl === "string"
11
- ? document.querySelectorAll(selectorOrEl)
12
- : selectorOrEl.querySelectorAll(selector || "")
13
- )
14
+ export function $$(selector: string): Element[]
15
+ export function $$(el: Element, selector: string): Element[]
16
+ export function $$(selectorOrEl: string | Element, selector?: string): Element[] {
17
+ return Array.from(
18
+ typeof selectorOrEl === "string"
19
+ ? document.querySelectorAll(selectorOrEl)
20
+ : selectorOrEl.querySelectorAll(selector!)
21
+ )
22
+ }
14
23
 
15
24
  // $create(tag, attrs): attrs are set as attributes, except className, which
16
25
  // may be a string or an array of class names.
@@ -87,11 +96,8 @@ function sanitizeNode(node: HTMLElement): HTMLElement | null {
87
96
  clean.setAttribute(name, attr.value);
88
97
  }
89
98
 
90
- // fuerza rel seguro en enlaces
91
- if (tag === 'a') {
92
- clean.setAttribute('rel', 'noopener noreferrer');
93
- if (clean.hasAttribute('target')) clean.removeAttribute('target');
94
- }
99
+ // fuerza rel seguro en enlaces (target nunca se copia: no está permitido)
100
+ if (tag === 'a') clean.setAttribute('rel', 'noopener noreferrer');
95
101
 
96
102
  appendSanitizedChildren(node, clean);
97
103
 
package/src/jq79.ts CHANGED
@@ -601,9 +601,15 @@ const runFactoryScript = (code: string, scope: Record<string, any>, effect: (run
601
601
  const merge = (bindings: any) => {
602
602
  if (bindings && typeof bindings === "object") Object.assign(scope, bindings)
603
603
  }
604
- const returned = factory({ $data: scope, $effect: effect, ...instanceHelpers })
605
- if (returned instanceof Promise) returned.then(merge).catch(logError)
606
- else merge(returned)
604
+ // the sync path is invoked straight from render(), so a throwing factory
605
+ // must be caught here too - not just by the `result` rejection handler
606
+ try {
607
+ const returned = factory({ $data: scope, $effect: effect, ...instanceHelpers })
608
+ if (returned instanceof Promise) returned.then(merge).catch(logError)
609
+ else merge(returned)
610
+ } catch (error) {
611
+ logError(error)
612
+ }
607
613
  }
608
614
 
609
615
  result.then(invoke, logError)
package/src/vite.ts CHANGED
@@ -37,7 +37,6 @@ const IMPORT_LITERAL_RE = /(?<![\w$.])import\s*\(\s*(["'])([^"'\n]+?)\1\s*\)/g
37
37
  const STATIC_IMPORT_LITERAL_RE = /(?<![\w$.])import\s*(?:[\w$\s,{}*]+?\s*from\s*)?(["'])([^"'\n]+)\1/g
38
38
 
39
39
  const isHtmlUrl = (spec: string) => /\.html?([?#]|$)/.test(spec)
40
- const isRelative = (spec: string) => spec.startsWith("./") || spec.startsWith("../")
41
40
  const isExternalUrl = (spec: string) => /^[a-z][a-z0-9+.-]*:/i.test(spec) || spec.startsWith("/")
42
41
 
43
42
  // literal import specifiers in the component's script blocks - dynamic