@domql/state
Advanced tools
Comparing version 2.5.15 to 2.5.16
'use strict' | ||
import { triggerEventOn } from '@domql/event' | ||
import { deepClone, exec, is, isArray, isFunction, isObject } from '@domql/utils' | ||
import { deepClone, exec, is, isArray, isFunction, isObject, isUndefined } from '@domql/utils' | ||
import { IGNORE_STATE_PARAMS } from './ignore' | ||
@@ -25,3 +25,3 @@ import { add, apply, clean, destroy, parentUpdate, parse, remove, rootUpdate, set, toggle } from './methods' | ||
const inheritedState = createInheritedState(element, parent) | ||
element.state = inheritedState || {} | ||
element.state = isUndefined(inheritedState) ? {} : inheritedState | ||
} | ||
@@ -66,3 +66,3 @@ | ||
return state | ||
} else { | ||
} else { | ||
return false | ||
@@ -69,0 +69,0 @@ } |
@@ -46,3 +46,3 @@ "use strict"; | ||
const inheritedState = (0, import_inherit.createInheritedState)(element, parent); | ||
element.state = inheritedState || {}; | ||
element.state = (0, import_utils.isUndefined)(inheritedState) ? {} : inheritedState; | ||
} | ||
@@ -49,0 +49,0 @@ const dependentState = applyDependentState(element, element.state); |
@@ -82,8 +82,8 @@ "use strict"; | ||
const inheritedState = findInheritedState(element, parent); | ||
if (!inheritedState) | ||
if ((0, import_utils.isUndefined)(inheritedState)) | ||
return element.state; | ||
if ((0, import_utils.is)(inheritedState)("object", "array")) { | ||
return (0, import_utils.deepClone)(inheritedState, import_ignore.IGNORE_STATE_PARAMS); | ||
} else if ((0, import_utils.is)(inheritedState)("string", "number")) { | ||
ref.__stateType = "string"; | ||
} else if ((0, import_utils.is)(inheritedState)("string", "number", "boolean")) { | ||
ref.__stateType = typeof inheritedState; | ||
return { value: inheritedState }; | ||
@@ -96,5 +96,5 @@ } | ||
const stateKey = ref.__state; | ||
if (!stateKey || (0, import_utils.isNot)(stateKey)("number", "string")) | ||
return false; | ||
return true; | ||
if (stateKey && (0, import_utils.is)(stateKey)("number", "string", "boolean")) | ||
return true; | ||
return false; | ||
}; | ||
@@ -101,0 +101,0 @@ const isState = function(state) { |
@@ -81,2 +81,3 @@ "use strict"; | ||
const stateKey = ref.__state; | ||
const stateType = ref.__stateType; | ||
if (!stateKey) | ||
@@ -89,3 +90,3 @@ return; | ||
return; | ||
const isStringState = ref.__stateType === "string"; | ||
const isStringState = stateType === "string" || stateType === "number" || stateType === "boolean"; | ||
const value = isStringState ? state.value : state.parse(); | ||
@@ -92,0 +93,0 @@ const passedValue = isStringState ? state.value : obj; |
'use strict' | ||
import { deepClone, is, isNot, isObjectLike } from '@domql/utils' | ||
import { deepClone, is, isObjectLike, isUndefined } from '@domql/utils' | ||
import { IGNORE_STATE_PARAMS } from './ignore' | ||
@@ -56,8 +56,8 @@ | ||
const inheritedState = findInheritedState(element, parent) | ||
if (!inheritedState) return element.state | ||
if (isUndefined(inheritedState)) return element.state | ||
if (is(inheritedState)('object', 'array')) { | ||
return deepClone(inheritedState, IGNORE_STATE_PARAMS) | ||
} else if (is(inheritedState)('string', 'number')) { | ||
ref.__stateType = 'string' | ||
} else if (is(inheritedState)('string', 'number', 'boolean')) { | ||
ref.__stateType = typeof inheritedState | ||
return { value: inheritedState } | ||
@@ -73,4 +73,4 @@ } | ||
if (!stateKey || isNot(stateKey)('number', 'string')) return false | ||
return true | ||
if (stateKey && is(stateKey)('number', 'string', 'boolean')) return true | ||
return false | ||
} | ||
@@ -77,0 +77,0 @@ |
{ | ||
"name": "@domql/state", | ||
"version": "2.5.15", | ||
"version": "2.5.16", | ||
"license": "MIT", | ||
@@ -34,3 +34,3 @@ "type": "module", | ||
}, | ||
"gitHead": "2d858d6237f30594a8bbe97c6aca8bc6dc925f85" | ||
"gitHead": "2987c1965a4cab0258feb592d273d519260f5461" | ||
} |
@@ -69,2 +69,3 @@ 'use strict' | ||
const stateKey = ref.__state | ||
const stateType = ref.__stateType | ||
if (!stateKey) return | ||
@@ -77,3 +78,3 @@ | ||
const isStringState = (ref.__stateType === 'string') | ||
const isStringState = (stateType === 'string' || stateType === 'number' || stateType === 'boolean') | ||
const value = isStringState ? state.value : state.parse() | ||
@@ -80,0 +81,0 @@ const passedValue = isStringState ? state.value : obj |
36747
962