@domql/state
Advanced tools
Comparing version 2.3.130 to 2.3.132
@@ -32,6 +32,6 @@ "use strict"; | ||
var import_ignore = require("./ignore"); | ||
const getParentStateInKey = (stateKey2, parentState) => { | ||
if (!stateKey2.includes("../")) | ||
const getParentStateInKey = (stateKey, parentState) => { | ||
if (!stateKey.includes("../")) | ||
return; | ||
const arr = stateKey2.split("../"); | ||
const arr = stateKey.split("../"); | ||
const arrLength = arr.length - 1; | ||
@@ -45,4 +45,4 @@ for (let i = 0; i < arrLength; i++) { | ||
}; | ||
const getChildStateInKey = (stateKey2, parentState, options) => { | ||
const arr = stateKey2.split("/"); | ||
const getChildStateInKey = (stateKey, parentState, options) => { | ||
const arr = stateKey.split("/"); | ||
const arrLength = arr.length - 1; | ||
@@ -54,3 +54,3 @@ for (let i = 0; i < arrLength; i++) { | ||
if (childInParent && childInParent[grandChildKey]) { | ||
stateKey2 = grandChildKey; | ||
stateKey = grandChildKey; | ||
parentState = childInParent; | ||
@@ -62,18 +62,18 @@ } else | ||
return parentState; | ||
return parentState[stateKey2]; | ||
return parentState[stateKey]; | ||
}; | ||
const findInheritedState = (element, parent, options = {}) => { | ||
const ref = element.__ref; | ||
let stateKey2 = ref.__state; | ||
let stateKey = ref.__state; | ||
if (!checkIfInherits(element)) | ||
return; | ||
let parentState = parent.state; | ||
const findGrandParentState = getParentStateInKey(stateKey2, parent.state); | ||
const findGrandParentState = getParentStateInKey(stateKey, parent.state); | ||
if (findGrandParentState) { | ||
parentState = findGrandParentState; | ||
stateKey2 = stateKey2.replaceAll("../", ""); | ||
stateKey = stateKey.replaceAll("../", ""); | ||
} | ||
if (!parentState) | ||
return; | ||
return getChildStateInKey(stateKey2, parentState, options); | ||
return getChildStateInKey(stateKey, parentState, options); | ||
}; | ||
@@ -91,8 +91,8 @@ const createInheritedState = (element, parent) => { | ||
} | ||
console.warn(stateKey, "is not present. Replacing with", {}); | ||
console.warn(ref.__state, "is not present. Replacing with", {}); | ||
}; | ||
const checkIfInherits = (element) => { | ||
const ref = element.__ref; | ||
const stateKey2 = ref.__state; | ||
if (!stateKey2 || (0, import_utils.isNot)(stateKey2)("number", "string")) | ||
const stateKey = ref.__state; | ||
if (!stateKey || (0, import_utils.isNot)(stateKey)("number", "string")) | ||
return false; | ||
@@ -112,3 +112,3 @@ return true; | ||
const keys = path.split("/"); | ||
let obj = {}; | ||
const obj = {}; | ||
let ref = obj; | ||
@@ -115,0 +115,0 @@ keys.forEach((key, index) => { |
@@ -128,4 +128,4 @@ "use strict"; | ||
func(state); | ||
return state.update(state, { overwrite: "replace", ...options }); | ||
return state.update(state, { replace: true, ...options }); | ||
} | ||
}; |
@@ -61,3 +61,3 @@ 'use strict' | ||
console.warn(stateKey, 'is not present. Replacing with', {}) | ||
console.warn(ref.__state, 'is not present. Replacing with', {}) | ||
} | ||
@@ -80,12 +80,12 @@ | ||
if (!path) { | ||
return value || {}; | ||
return value || {} | ||
} | ||
const keys = path.split('/'); | ||
let obj = {}; | ||
let ref = obj; | ||
const keys = path.split('/') | ||
const obj = {} | ||
let ref = obj | ||
keys.forEach((key, index) => { | ||
ref[key] = index === keys.length - 1 ? value || {} : {}; | ||
ref = ref[key]; | ||
}); | ||
return obj; | ||
ref[key] = index === keys.length - 1 ? value || {} : {} | ||
ref = ref[key] | ||
}) | ||
return obj | ||
} |
@@ -111,4 +111,4 @@ 'use strict' | ||
func(state) | ||
return state.update(state, { overwrite: 'replace', ...options }) | ||
return state.update(state, { replace: true, ...options }) | ||
} | ||
} |
{ | ||
"name": "@domql/state", | ||
"version": "2.3.130", | ||
"version": "2.3.132", | ||
"license": "MIT", | ||
@@ -29,3 +29,3 @@ "type": "module", | ||
}, | ||
"gitHead": "6160195e1279dda74af7a092e863e4bbf397e81e" | ||
"gitHead": "2df037bb2c72a090715d27e3368c39c605dac733" | ||
} |
34133