New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@domql/state

Package Overview
Dependencies
Maintainers
3
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@domql/state - npm Package Compare versions

Comparing version 2.3.120 to 2.3.121

72

createState.js

@@ -12,38 +12,21 @@ 'use strict'

const skip = (opts && opts.skip) ? opts.skip : false
let { state, __ref: __elementRef } = element
state = element.state = checkForTypes(element)
const objectizeState = checkForTypes(element)
if (objectizeState === false) return parent.state || {}
else element.state = objectizeState
triggerEventOn('stateInit', element)
const whatInitReturns = triggerEventOn('stateInit', element)
if (whatInitReturns === false) return element.state
if (checkIfInherits(element)) {
state = element.state = createInheritedState(element, parent) || {}
element.state = createInheritedState(element, parent) || {}
}
if (!state) {
if (parent && parent.state) return parent.state
return {}
} else {
__elementRef.__hasRootState = true
}
const dependentState = applyDependentState(element, state)
if (dependentState) element.state = dependentState
// reference other state
// TODO: check why __ref is assigned with element
// /docs/intro
const { __ref } = state
if (__ref) {
state = deepClone(__ref, IGNORE_STATE_PARAMS)
if (isObject(__ref.__depends)) {
__ref.__depends[element.key] = state
} else __ref.__depends = { [element.key]: state }
} else {
state = deepClone(state, IGNORE_STATE_PARAMS)
}
element.state = state
// NOTE: Only true when 'onlyResolveExtends' option is set to true
if (skip) return state
if (skip) return element.state
applyMethods(element, state)
applyMethods(element)

@@ -53,24 +36,41 @@ // trigger `on.stateCreated`

return state
return element.state
}
const applyDependentState = (element, state) => {
const { __ref: ref } = state
if (!ref) return
const dependentState = deepClone(ref, IGNORE_STATE_PARAMS)
const newDepends = { [element.key]: dependentState }
ref.__depends = isObject(ref.__depends)
? { ...ref.__depends, ...newDepends }
: newDepends
return dependentState
}
const checkForTypes = (element) => {
const { state, __ref: __elementRef } = element
const { state, __ref: ref } = element
if (isFunction(state)) {
__elementRef.__state = state
ref.__state = state
return exec(state, element)
}
if (is(state)('string', 'number')) {
__elementRef.__state = state
ref.__state = state
return {}
}
if (state === true) {
__elementRef.__state = element.key
ref.__state = element.key
return {}
}
return state
if (state) {
ref.__hasRootState = true
return state
}
return false
}
const applyMethods = (element, state) => {
const __elementRef = element.__ref
const applyMethods = (element) => {
const state = element.state
const ref = element.__ref

@@ -90,5 +90,5 @@ state.clean = clean

state.__children = {}
state.__root = __elementRef.__root ? __elementRef.__root.state : state
state.__root = ref.__root ? ref.__root.state : state
if (state.parent) state.parent.__children[element.key] = state
}

@@ -32,66 +32,70 @@ "use strict";

const skip = opts && opts.skip ? opts.skip : false;
let { state, __ref: __elementRef } = element;
state = element.state = checkForTypes(element);
(0, import_event.triggerEventOn)("stateInit", element);
const objectizeState = checkForTypes(element);
if (objectizeState === false)
return parent.state || {};
else
element.state = objectizeState;
const whatInitReturns = (0, import_event.triggerEventOn)("stateInit", element);
if (whatInitReturns === false)
return element.state;
if ((0, import_utils2.checkIfInherits)(element)) {
state = element.state = (0, import_utils2.createInheritedState)(element, parent) || {};
element.state = (0, import_utils2.createInheritedState)(element, parent) || {};
}
if (!state) {
if (parent && parent.state)
return parent.state;
return {};
} else {
__elementRef.__hasRootState = true;
}
const { __ref } = state;
if (__ref) {
state = (0, import_utils.deepClone)(__ref, import_ignore.IGNORE_STATE_PARAMS);
if ((0, import_utils.isObject)(__ref.__depends)) {
__ref.__depends[element.key] = state;
} else
__ref.__depends = { [element.key]: state };
} else {
state = (0, import_utils.deepClone)(state, import_ignore.IGNORE_STATE_PARAMS);
}
element.state = state;
const dependentState = applyDependentState(element, state);
if (dependentState)
element.state = dependentState;
if (skip)
return state;
applyMethods(element, state);
return element.state;
applyMethods(element);
(0, import_event.triggerEventOn)("stateCreated", element);
return state;
return element.state;
};
const applyDependentState = (element, state2) => {
const { __ref: ref } = state2;
if (!ref)
return;
const dependentState = (0, import_utils.deepClone)(ref, import_ignore.IGNORE_STATE_PARAMS);
const newDepends = { [element.key]: dependentState };
ref.__depends = (0, import_utils.isObject)(ref.__depends) ? { ...ref.__depends, ...newDepends } : newDepends;
return dependentState;
};
const checkForTypes = (element) => {
const { state, __ref: __elementRef } = element;
if ((0, import_utils.isFunction)(state)) {
__elementRef.__state = state;
return (0, import_utils.exec)(state, element);
const { state: state2, __ref: ref } = element;
if ((0, import_utils.isFunction)(state2)) {
ref.__state = state2;
return (0, import_utils.exec)(state2, element);
}
if ((0, import_utils.is)(state)("string", "number")) {
__elementRef.__state = state;
if ((0, import_utils.is)(state2)("string", "number")) {
ref.__state = state2;
return {};
}
if (state === true) {
__elementRef.__state = element.key;
if (state2 === true) {
ref.__state = element.key;
return {};
}
return state;
if (state2) {
ref.__hasRootState = true;
return state2;
}
return false;
};
const applyMethods = (element, state) => {
const __elementRef = element.__ref;
state.clean = import_methods.clean;
state.parse = import_methods.parse;
state.destroy = import_methods.destroy;
state.update = import_updateState.updateState;
state.rootUpdate = import_methods.rootUpdate;
state.create = createState;
state.add = import_methods.add;
state.toggle = import_methods.toggle;
state.remove = import_methods.remove;
state.apply = import_methods.apply;
state.parent = element.parent.state;
state.__element = element;
state.__children = {};
state.__root = __elementRef.__root ? __elementRef.__root.state : state;
if (state.parent)
state.parent.__children[element.key] = state;
const applyMethods = (element) => {
const state2 = element.state;
const ref = element.__ref;
state2.clean = import_methods.clean;
state2.parse = import_methods.parse;
state2.destroy = import_methods.destroy;
state2.update = import_updateState.updateState;
state2.rootUpdate = import_methods.rootUpdate;
state2.create = createState;
state2.add = import_methods.add;
state2.toggle = import_methods.toggle;
state2.remove = import_methods.remove;
state2.apply = import_methods.apply;
state2.parent = element.parent.state;
state2.__element = element;
state2.__children = {};
state2.__root = ref.__root ? ref.__root.state : state2;
if (state2.parent)
state2.parent.__children[element.key] = state2;
};

@@ -41,3 +41,3 @@ "use strict";

hoistStateUpdate(state, obj, options);
applyDependentState(state, obj, options);
updateDependentState(state, obj, options);
applyElementUpdate(state, obj, options);

@@ -64,23 +64,25 @@ if (!options.preventStateUpdateListener) {

const stateKey = __elementRef.__state;
const hasParentState = (0, import_utils2.checkIfInherits)(element);
const shouldPropagateState = stateKey && hasParentState && !options.stopStatePropagation;
if (!stateKey)
return;
const asksForInherit = (0, import_utils2.checkIfInherits)(element);
const shouldPropagateState = asksForInherit && !options.stopStatePropagation;
const parentState = element.parent.state;
if (shouldPropagateState) {
const isStringState = __elementRef.__stateType === "string";
const value = isStringState ? state.value : state.parse();
const passedValue = isStringState ? state.value : obj;
parentState[stateKey] = value;
parentState.update({ [stateKey]: passedValue }, {
skipOverwrite: true,
preventUpdate: options.preventHoistElementUpdate,
...options
});
}
if (!shouldPropagateState)
return;
const isStringState = __elementRef.__stateType === "string";
const value = isStringState ? state.value : state.parse();
const passedValue = isStringState ? state.value : obj;
parentState[stateKey] = value;
parentState.update({ [stateKey]: passedValue }, {
skipOverwrite: true,
preventUpdate: options.preventHoistElementUpdate,
...options
});
};
const applyDependentState = (state, obj, options) => {
if (state.__depends) {
for (const el in state.__depends) {
const findElement = state.__depends[el];
findElement.clean().update(state.parse(), options);
}
const updateDependentState = (state, obj, options) => {
if (!state.__depends)
return;
for (const el in state.__depends) {
const dependentState = state.__depends[el];
dependentState.clean().update(state.parse(), options);
}

@@ -87,0 +89,0 @@ };

{
"name": "@domql/state",
"version": "2.3.120",
"version": "2.3.121",
"license": "MIT",

@@ -29,3 +29,3 @@ "type": "module",

},
"gitHead": "6e932a813b8e6ee0a57a40ebc6dc757cc44e6427"
"gitHead": "7bb63fd5aab7bfa92c0aaa3a7205ff9a002fac1c"
}

@@ -24,3 +24,3 @@ 'use strict'

applyDependentState(state, obj, options)
updateDependentState(state, obj, options)

@@ -54,26 +54,26 @@ applyElementUpdate(state, obj, options)

const stateKey = __elementRef.__state
const hasParentState = checkIfInherits(element)
const shouldPropagateState = stateKey && hasParentState && !options.stopStatePropagation
if (!stateKey) return
const asksForInherit = checkIfInherits(element)
const shouldPropagateState = asksForInherit && !options.stopStatePropagation
const parentState = element.parent.state
if (shouldPropagateState) {
const isStringState = (__elementRef.__stateType === 'string')
const value = isStringState ? state.value : state.parse()
const passedValue = isStringState ? state.value : obj
if (!shouldPropagateState) return
const isStringState = (__elementRef.__stateType === 'string')
const value = isStringState ? state.value : state.parse()
const passedValue = isStringState ? state.value : obj
parentState[stateKey] = value
parentState.update({ [stateKey]: passedValue }, {
skipOverwrite: true,
preventUpdate: options.preventHoistElementUpdate,
...options
})
}
parentState[stateKey] = value
parentState.update({ [stateKey]: passedValue }, {
skipOverwrite: true,
preventUpdate: options.preventHoistElementUpdate,
...options
})
}
const applyDependentState = (state, obj, options) => {
if (state.__depends) {
for (const el in state.__depends) {
const findElement = state.__depends[el]
findElement.clean().update(state.parse(), options)
}
const updateDependentState = (state, obj, options) => {
if (!state.__depends) return
for (const el in state.__depends) {
const dependentState = state.__depends[el]
dependentState.clean().update(state.parse(), options)
}

@@ -80,0 +80,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc