@maverick-js/signals
Advanced tools
Comparing version 5.10.5 to 5.11.0
import { SCOPE } from './symbols.js'; | ||
let scheduledEffects = false, runningEffects = false, currentScope = null, currentObserver = null, currentObservers = null, currentObserversIndex = 0, effects = []; | ||
let scheduledEffects = false, runningEffects = false, currentScope = null, currentObserver = null, currentObservers = null, currentObserversIndex = 0, effects = [], defaultContext = {}; | ||
const NOOP = () => { | ||
@@ -69,3 +69,3 @@ }, STATE_CLEAN = 0, STATE_CHECK = 1, STATE_DIRTY = 2, STATE_DISPOSED = 3; | ||
return; | ||
currentScope._handlers = [handler, ...currentScope._handlers]; | ||
currentScope._handlers = currentScope._handlers ? [handler, ...currentScope._handlers] : [handler]; | ||
} | ||
@@ -122,3 +122,3 @@ function onDispose(disposable) { | ||
node._prevSibling = null; | ||
node._context = null; | ||
node._context = defaultContext; | ||
node._handlers = null; | ||
@@ -153,3 +153,3 @@ } | ||
function handleError(scope, error) { | ||
if (!scope) | ||
if (!scope || !scope._handlers) | ||
throw error; | ||
@@ -206,11 +206,9 @@ let i = 0, len = scope._handlers.length, coercedError = coerceError(error); | ||
const ScopeProto = ScopeNode.prototype; | ||
ScopeProto._context = {}; | ||
ScopeProto._handlers = []; | ||
ScopeProto._context = defaultContext; | ||
ScopeProto._handlers = null; | ||
ScopeProto._compute = null; | ||
ScopeProto._disposal = null; | ||
ScopeProto.append = function appendScope(scope) { | ||
ScopeProto.append = function(scope) { | ||
scope[SCOPE] = this; | ||
scope._prevSibling = this; | ||
scope._context = this._context; | ||
scope._handlers = this._handlers; | ||
if (this._nextSibling) | ||
@@ -220,3 +218,10 @@ this._nextSibling._prevSibling = scope; | ||
this._nextSibling = scope; | ||
scope._context = scope._context === defaultContext ? this._context : { ...this._context, ...scope._context }; | ||
if (this._handlers) { | ||
scope._handlers = !scope._handlers ? this._handlers : [...scope._handlers, ...this._handlers]; | ||
} | ||
}; | ||
ScopeProto.dispose = function() { | ||
dispose.call(this); | ||
}; | ||
function createScope() { | ||
@@ -271,3 +276,3 @@ return new ScopeNode(); | ||
emptyDisposal(node); | ||
node._handlers = node[SCOPE]?._handlers || []; | ||
node._handlers = node[SCOPE] ? node[SCOPE]._handlers : null; | ||
} | ||
@@ -274,0 +279,0 @@ function update(node) { |
import { SCOPE } from './symbols.js'; | ||
let scheduledEffects = false, runningEffects = false, currentScope = null, currentObserver = null, currentObservers = null, currentObserversIndex = 0, effects = []; | ||
let scheduledEffects = false, runningEffects = false, currentScope = null, currentObserver = null, currentObservers = null, currentObserversIndex = 0, effects = [], defaultContext = {}; | ||
const NOOP = () => { | ||
@@ -69,3 +69,3 @@ }, STATE_CLEAN = 0, STATE_CHECK = 1, STATE_DIRTY = 2, STATE_DISPOSED = 3; | ||
return; | ||
currentScope.$eh = [handler, ...currentScope.$eh]; | ||
currentScope.$eh = currentScope.$eh ? [handler, ...currentScope.$eh] : [handler]; | ||
} | ||
@@ -122,3 +122,3 @@ function onDispose(disposable) { | ||
node.$ps = null; | ||
node.$cx = null; | ||
node.$cx = defaultContext; | ||
node.$eh = null; | ||
@@ -153,3 +153,3 @@ } | ||
function handleError(scope, error) { | ||
if (!scope) | ||
if (!scope || !scope.$eh) | ||
throw error; | ||
@@ -206,11 +206,9 @@ let i = 0, len = scope.$eh.length, coercedError = coerceError(error); | ||
const ScopeProto = ScopeNode.prototype; | ||
ScopeProto.$cx = {}; | ||
ScopeProto.$eh = []; | ||
ScopeProto.$cx = defaultContext; | ||
ScopeProto.$eh = null; | ||
ScopeProto.$c = null; | ||
ScopeProto.$d = null; | ||
ScopeProto.append = function appendScope(scope) { | ||
ScopeProto.append = function(scope) { | ||
scope[SCOPE] = this; | ||
scope.$ps = this; | ||
scope.$cx = this.$cx; | ||
scope.$eh = this.$eh; | ||
if (this.$ns) | ||
@@ -220,3 +218,10 @@ this.$ns.$ps = scope; | ||
this.$ns = scope; | ||
scope.$cx = scope.$cx === defaultContext ? this.$cx : { ...this.$cx, ...scope.$cx }; | ||
if (this.$eh) { | ||
scope.$eh = !scope.$eh ? this.$eh : [...scope.$eh, ...this.$eh]; | ||
} | ||
}; | ||
ScopeProto.dispose = function() { | ||
dispose.call(this); | ||
}; | ||
function createScope() { | ||
@@ -270,3 +275,3 @@ return new ScopeNode(); | ||
emptyDisposal(node); | ||
node.$eh = node[SCOPE]?.$eh || []; | ||
node.$eh = node[SCOPE] ? node[SCOPE].$eh : null; | ||
} | ||
@@ -273,0 +278,0 @@ function update(node) { |
@@ -59,2 +59,3 @@ import type { SCOPE } from './symbols'; | ||
append(scope: Scope): void; | ||
dispose(): void; | ||
} | ||
@@ -61,0 +62,0 @@ export interface Dispose { |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "5.10.5", | ||
"version": "5.11.0", | ||
"type": "module", | ||
@@ -8,0 +8,0 @@ "types": "dist/types/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63856
1400