Solved 2 bugs

This commit is contained in:
2026-04-13 17:52:26 +02:00
parent 627cfcd5d5
commit cf0e5b2913

View File

@@ -47,8 +47,8 @@ const createEffect = (fn, isComputed = false) => {
const prevOwner = activeOwner const prevOwner = activeOwner
activeEffect = activeOwner = effect activeEffect = activeOwner = effect
try { try {
const res = isComputed ? fn() : (fn(), undefined) const res = fn()
if (!isComputed) effect._result = res effect._result = res
return res return res
} finally { } finally {
activeEffect = prevEffect activeEffect = prevEffect
@@ -77,7 +77,7 @@ const flush = () => {
const trackUpdate = (subs, trigger = false) => { const trackUpdate = (subs, trigger = false) => {
if (!trigger && activeEffect && !activeEffect._disposed) { if (!trigger && activeEffect && !activeEffect._disposed) {
subs.add(activeEffect) subs.add(activeEffect)
;(activeEffect._deps ||= new Set()).add(subs) ; (activeEffect._deps ||= new Set()).add(subs)
} else if (trigger) { } else if (trigger) {
let hasQueue = false let hasQueue = false
subs.forEach(e => { subs.forEach(e => {
@@ -141,7 +141,7 @@ const $ = (val, key = null) => {
if (activeOwner) onUnmount(computed.stop) if (activeOwner) onUnmount(computed.stop)
return computed return computed
} }
if (key) try { val = JSON.parse(localStorage.getItem(key)) ?? val } catch (e) {} if (key) try { val = JSON.parse(localStorage.getItem(key)) ?? val } catch (e) { }
return (...args) => { return (...args) => {
if (args.length) { if (args.length) {
const next = isFunc(args[0]) ? args[0](val) : args[0] const next = isFunc(args[0]) ? args[0](val) : args[0]
@@ -304,10 +304,12 @@ const Render = renderFn => {
const cleanups = new Set() const cleanups = new Set()
const mounts = [] const mounts = []
const previousOwner = activeOwner const previousOwner = activeOwner
const previousEffect = activeEffect
const container = doc.createElement("div") const container = doc.createElement("div")
container.style.display = "contents" container.style.display = "contents"
container.setAttribute("role", "presentation") // ← único cambio real container.setAttribute("role", "presentation") // ← único cambio real
activeOwner = { _cleanups: cleanups, _mounts: mounts } activeOwner = { _cleanups: cleanups, _mounts: mounts }
activeEffect = null
const processResult = result => { const processResult = result => {
if (!result) return if (!result) return
@@ -452,16 +454,16 @@ const Mount = (comp, target) => {
} }
const set = (signal, path, value) => { const set = (signal, path, value) => {
if (value === undefined) { if (value === undefined) {
signal(isFunc(path) ? path(signal()) : path); signal(isFunc(path) ? path(signal()) : path);
} else { } else {
const keys = path.split('.'); const keys = path.split('.');
const last = keys.pop(); const last = keys.pop();
const current = signal(); const current = signal();
const obj = keys.reduce((o, k) => ({ ...o, [k]: { ...o[k] } }), { ...current }); const obj = keys.reduce((o, k) => ({ ...o, [k]: { ...o[k] } }), { ...current });
obj[last] = value; obj[last] = value;
signal(obj); signal(obj);
} }
}; };
const SigPro = Object.freeze({ $, Watch, Tag, Render, If, For, Router, Mount, onMount, onUnmount, set }) const SigPro = Object.freeze({ $, Watch, Tag, Render, If, For, Router, Mount, onMount, onUnmount, set })