@domql/element
Advanced tools
@@ -66,8 +66,6 @@ "use strict"; | ||
await (0, import_state.createState)(element, parent); | ||
if (element.scope === "state") | ||
element.scope = element.state; | ||
if (element.scope === "state") element.scope = element.state; | ||
createIfConditionFlag(element, parent); | ||
(0, import_props.createProps)(element, parent, options); | ||
if (element.scope === "props" || element.scope === true) | ||
element.scope = element.props; | ||
if (element.scope === "props" || element.scope === true) element.scope = element.props; | ||
createIfConditionFlag(element, parent); | ||
@@ -79,4 +77,3 @@ if (element.node && ref.__if) { | ||
const onInit = await (0, import_event.triggerEventOn)("init", element, options); | ||
if (onInit === false) | ||
return element; | ||
if (onInit === false) return element; | ||
(0, import_event.triggerEventOn)("beforeClassAssign", element, options); | ||
@@ -97,3 +94,3 @@ (0, import_classList.assignKeyAsClassname)(element); | ||
} | ||
if ((0, import_utils.isString)(key) && key.slice(0, 2 === "__")) { | ||
if ((0, import_utils.isString)(key) && key.slice(0, false)) { | ||
if (ENV === "test" || ENV === "development") { | ||
@@ -103,6 +100,4 @@ console.warn(key, "seems like to be in __ref"); | ||
} | ||
if (element === null) | ||
return; | ||
if (element === true) | ||
return { text: true }; | ||
if (element === null) return; | ||
if (element === true) return { text: true }; | ||
if (element.__hash) { | ||
@@ -116,6 +111,4 @@ return { extend: element }; | ||
if (options.syntaxv3 || element.props && element.props.syntaxv3 || parent && parent.props && parent.props.syntaxv3) { | ||
if (element.props) | ||
element.props.syntaxv3 = true; | ||
else | ||
element.syntaxv3 = true; | ||
if (element.props) element.props.syntaxv3 = true; | ||
else element.syntaxv3 = true; | ||
return (0, import_component.createValidDomqlObjectFromSugar)(element, parent, key, options); | ||
@@ -131,4 +124,3 @@ } else if ((0, import_utils.checkIfKeyIsComponent)(key)) { | ||
const redefineParent = (element, parent, key, options) => { | ||
if (!parent) | ||
return import_tree.ROOT; | ||
if (!parent) return import_tree.ROOT; | ||
if ((0, import_utils.isNode)(parent)) { | ||
@@ -151,6 +143,4 @@ const parentNodeWrapper = { key: ":root", node: parent }; | ||
const addRef = (element, parent) => { | ||
if (element.__ref) | ||
element.__ref.origin = element; | ||
else | ||
element.__ref = { origin: element }; | ||
if (element.__ref) element.__ref.origin = element; | ||
else element.__ref = { origin: element }; | ||
return element.__ref; | ||
@@ -161,9 +151,7 @@ }; | ||
import_mixins.registry.defaultOptions = options; | ||
if (options.ignoreChildExtend) | ||
delete options.ignoreChildExtend; | ||
if (options.ignoreChildExtend) delete options.ignoreChildExtend; | ||
} | ||
}; | ||
const addElementIntoParentChildren = (element, parent) => { | ||
if (parent.__ref && parent.__ref.__children) | ||
parent.__ref.__children.push(element.key); | ||
if (parent.__ref && parent.__ref.__children) parent.__ref.__children.push(element.key); | ||
}; | ||
@@ -174,4 +162,3 @@ const visitedElements = /* @__PURE__ */ new WeakMap(); | ||
if (visitedElements.has(element)) { | ||
if (ENV === "test" || ENV === "development") | ||
console.warn("Cyclic rendering detected:", element.__ref.path); | ||
if (ENV === "test" || ENV === "development") console.warn("Cyclic rendering detected:", element.__ref.path); | ||
} | ||
@@ -182,4 +169,3 @@ visitedElements.set(element, true); | ||
const isInfiniteLoopDetected = (0, import_utils.detectInfiniteLoop)(ref.path); | ||
if (ref.__uniqId || isInfiniteLoopDetected) | ||
return; | ||
if (ref.__uniqId || isInfiniteLoopDetected) return; | ||
await (0, import_node.createNode)(element, options); | ||
@@ -195,6 +181,4 @@ ref.__uniqId = Math.random(); | ||
const path = ref.path; | ||
if (path.includes("ComponentsGrid")) | ||
path.splice(0, path.indexOf("ComponentsGrid") + 2); | ||
if (path.includes("demoComponent")) | ||
path.splice(0, path.indexOf("demoComponent") + 1); | ||
if (path.includes("ComponentsGrid")) path.splice(0, path.indexOf("ComponentsGrid") + 2); | ||
if (path.includes("demoComponent")) path.splice(0, path.indexOf("demoComponent") + 1); | ||
const isDemoComponent = (_b = (_a = element.lookup((el) => el.state.key)) == null ? void 0 : _a.state) == null ? void 0 : _b.key; | ||
@@ -204,6 +188,4 @@ element.warn("Error happened in:", isDemoComponent ? isDemoComponent + " " : "" + path.join(".")); | ||
element.error(e, options); | ||
if ((_c = element.on) == null ? void 0 : _c.error) | ||
element.on.error(e, element, element.state, element.context, options); | ||
if ((_d = element.props) == null ? void 0 : _d.onError) | ||
element.props.onError(e, element, element.state, element.context, options); | ||
if ((_c = element.on) == null ? void 0 : _c.error) element.on.error(e, element, element.state, element.context, options); | ||
if ((_d = element.props) == null ? void 0 : _d.onError) element.props.onError(e, element, element.state, element.context, options); | ||
} | ||
@@ -235,11 +217,8 @@ } | ||
const forcedOptionsContext = options.context && !import_tree.ROOT.context && !element.context; | ||
if (forcedOptionsContext) | ||
import_tree.ROOT.context = options.context; | ||
if (!element.context) | ||
element.context = parent.context || options.context || import_tree.ROOT.context; | ||
if (forcedOptionsContext) import_tree.ROOT.context = options.context; | ||
if (!element.context) element.context = parent.context || options.context || import_tree.ROOT.context; | ||
}; | ||
const createScope = (element, parent) => { | ||
const { __ref: ref } = element; | ||
if (!element.scope) | ||
element.scope = parent.scope || ref.root.scope || {}; | ||
if (!element.scope) element.scope = parent.scope || ref.root.scope || {}; | ||
}; | ||
@@ -250,4 +229,3 @@ const createIfConditionFlag = (element, parent) => { | ||
delete ref.__if; | ||
} else | ||
ref.__if = true; | ||
} else ref.__if = true; | ||
}; | ||
@@ -257,31 +235,17 @@ const addCaching = (element, parent) => { | ||
let { __ref: parentRef } = parent; | ||
if (!element.transform) | ||
element.transform = {}; | ||
if (!ref.__cached) | ||
ref.__cached = {}; | ||
if (!ref.__defineCache) | ||
ref.__defineCache = {}; | ||
if (!ref.__exec) | ||
ref.__exec = {}; | ||
if (!ref.__execProps) | ||
ref.__execProps = {}; | ||
if (!ref.__class) | ||
ref.__class = {}; | ||
if (!ref.__classNames) | ||
ref.__classNames = {}; | ||
if (!ref.__attr) | ||
ref.__attr = {}; | ||
if (!ref.__changes) | ||
ref.__changes = []; | ||
if (!ref.__children) | ||
ref.__children = []; | ||
if ((0, import_utils.checkIfKeyIsComponent)(key)) | ||
ref.__componentKey = key.split("_")[0].split(".")[0].split("+")[0]; | ||
if (!element.transform) element.transform = {}; | ||
if (!ref.__cached) ref.__cached = {}; | ||
if (!ref.__defineCache) ref.__defineCache = {}; | ||
if (!ref.__exec) ref.__exec = {}; | ||
if (!ref.__execProps) ref.__execProps = {}; | ||
if (!ref.__class) ref.__class = {}; | ||
if (!ref.__classNames) ref.__classNames = {}; | ||
if (!ref.__attr) ref.__attr = {}; | ||
if (!ref.__changes) ref.__changes = []; | ||
if (!ref.__children) ref.__children = []; | ||
if ((0, import_utils.checkIfKeyIsComponent)(key)) ref.__componentKey = key.split("_")[0].split(".")[0].split("+")[0]; | ||
const hasRoot = parent && parent.key === ":root"; | ||
if (!ref.root) | ||
ref.root = hasRoot ? element : parentRef.root; | ||
if (!parentRef) | ||
parentRef = parent.ref = {}; | ||
if (!parentRef.path) | ||
parentRef.path = []; | ||
if (!ref.root) ref.root = hasRoot ? element : parentRef.root; | ||
if (!parentRef) parentRef = parent.ref = {}; | ||
if (!parentRef.path) parentRef.path = []; | ||
ref.path = parentRef.path.concat(element.key); | ||
@@ -296,13 +260,10 @@ }; | ||
(0, import_state.createState)(element, parent); | ||
if (element.scope === "state") | ||
element.scope = element.state; | ||
if (element.scope === "state") element.scope = element.state; | ||
createIfConditionFlag(element, parent); | ||
(0, import_props.createProps)(element, parent, options); | ||
if (element.scope === "props" || element.scope === true) | ||
element.scope = element.props; | ||
if (element.scope === "props" || element.scope === true) element.scope = element.props; | ||
if (element.node && ref.__if) { | ||
parent[key || element.key] = element; | ||
} | ||
if (!element.props) | ||
element.props = {}; | ||
if (!element.props) element.props = {}; | ||
(0, import_component.applyVariant)(element, parent); | ||
@@ -315,4 +276,3 @@ addElementIntoParentChildren(element, parent); | ||
for (const k in element) { | ||
if ((0, import_utils.isUndefined)(element[k]) || (0, import_methods.isMethod)(k, element) || (0, import_utils.isObject)((import_mixins.registry.default || import_mixins.registry)[k]) || (0, import_utils.isVariant)(k)) | ||
continue; | ||
if ((0, import_utils.isUndefined)(element[k]) || (0, import_methods.isMethod)(k, element) || (0, import_utils.isObject)((import_mixins.registry.default || import_mixins.registry)[k]) || (0, import_utils.isVariant)(k)) continue; | ||
const hasDefine = element.define && element.define[k]; | ||
@@ -342,6 +302,4 @@ const contextHasDefine = element.context && element.context.define && element.context.define[k]; | ||
props.display = "none"; | ||
if (props[key]) | ||
props[key].display = props.display; | ||
else | ||
props[key] = { display: props.display || "block" }; | ||
if (props[key]) props[key].display = props.display; | ||
else props[key] = { display: props.display || "block" }; | ||
return element; | ||
@@ -348,0 +306,0 @@ } else { |
@@ -31,5 +31,4 @@ "use strict"; | ||
(0, import_report.report)("OverwriteToBuiltin", param); | ||
} else | ||
import_mixins.REGISTRY[param] = params[param]; | ||
} else import_mixins.REGISTRY[param] = params[param]; | ||
} | ||
}; |
@@ -29,4 +29,3 @@ "use strict"; | ||
const applyExtend = (element, parent, options = {}) => { | ||
if ((0, import_utils.isFunction)(element)) | ||
element = (0, import_utils.exec)(element, parent); | ||
if ((0, import_utils.isFunction)(element)) element = (0, import_utils.exec)(element, parent); | ||
const { props, __ref } = element; | ||
@@ -38,4 +37,3 @@ let extend = (props == null ? void 0 : props.extends) || element.extends || element.extend; | ||
const extendStack = (0, import_utils2.getExtendStack)(extend, context); | ||
if (ENV !== "test" || ENV !== "development") | ||
delete element.extend; | ||
if (ENV !== "test" || ENV !== "development") delete element.extend; | ||
let childExtendStack = []; | ||
@@ -66,4 +64,3 @@ if (parent) { | ||
stack = childExtendStack; | ||
} else if (!context.defaultExtends) | ||
return element; | ||
} else if (!context.defaultExtends) return element; | ||
if (context.defaultExtends) { | ||
@@ -77,4 +74,3 @@ if (!mainExtend) { | ||
} | ||
if (__ref) | ||
__ref.__extend = stack; | ||
if (__ref) __ref.__extend = stack; | ||
let mergedExtend = (0, import_utils2.cloneAndMergeArrayExtend)(stack); | ||
@@ -81,0 +77,0 @@ const COMPONENTS = context && context.components || options.components; |
@@ -29,4 +29,4 @@ "use strict"; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var element_exports = {}; | ||
__export(element_exports, { | ||
var index_exports = {}; | ||
__export(index_exports, { | ||
TREE: () => import_tree.TREE, | ||
@@ -39,3 +39,3 @@ create: () => import_create.default, | ||
}); | ||
module.exports = __toCommonJS(element_exports); | ||
module.exports = __toCommonJS(index_exports); | ||
var import_tree = require("./tree"); | ||
@@ -42,0 +42,0 @@ var import_create = __toESM(require("./create"), 1); |
@@ -34,4 +34,3 @@ "use strict"; | ||
for (const param in element) { | ||
if (exclude[param]) | ||
continue; | ||
if (exclude[param]) continue; | ||
const prop = element[param]; | ||
@@ -50,4 +49,3 @@ if ((0, import_utils.isFunction)(prop) && !(0, import_methods.isMethod)(param, element) && !(0, import_utils.isVariant)(param)) { | ||
const isDefinedParam = ref.__defineCache[param]; | ||
if (isDefinedParam) | ||
continue; | ||
if (isDefinedParam) continue; | ||
const newExec = ref.__exec[param](element, element.state, element.context); | ||
@@ -87,6 +85,4 @@ const execReturnsString = (0, import_utils.isString)(newExec) || (0, import_utils.isNumber)(newExec); | ||
const hasGlobalDefine = context && (0, import_utils.isObject)(context.define); | ||
if ((0, import_utils.isObject)(define)) | ||
defineObj = { ...define }; | ||
if (hasGlobalDefine) | ||
defineObj = { ...defineObj, ...context.define }; | ||
if ((0, import_utils.isObject)(define)) defineObj = { ...define }; | ||
if (hasGlobalDefine) defineObj = { ...defineObj, ...context.define }; | ||
for (const param in defineObj) { | ||
@@ -103,4 +99,3 @@ let elementProp = element[param]; | ||
const execParam = defineObj[param](elementProp, element, element.state, element.context); | ||
if (execParam) | ||
element[param] = execParam; | ||
if (execParam) element[param] = execParam; | ||
} | ||
@@ -113,16 +108,12 @@ return element; | ||
let obj = {}; | ||
if ((0, import_utils.isObject)(define)) | ||
obj = { ...define }; | ||
if ((0, import_utils.isObject)(context && context.define)) | ||
obj = { ...obj, ...context.define }; | ||
if ((0, import_utils.isObject)(define)) obj = { ...define }; | ||
if ((0, import_utils.isObject)(context && context.define)) obj = { ...obj, ...context.define }; | ||
for (const param in obj) { | ||
const execParam = ref.__exec[param]; | ||
if (execParam) | ||
ref.__defineCache[param] = execParam(element, element.state, element.context); | ||
if (execParam) ref.__defineCache[param] = execParam(element, element.state, element.context); | ||
const cached = (0, import_utils.exec)(ref.__defineCache[param], element); | ||
const newExecParam = obj[param](cached, element, element.state, element.context); | ||
if (newExecParam) | ||
element[param] = newExecParam; | ||
if (newExecParam) element[param] = newExecParam; | ||
} | ||
return changes; | ||
}; |
@@ -56,11 +56,8 @@ "use strict"; | ||
let active = import_tree.TREE[arr[0]]; | ||
if (!arr || !arr.length) | ||
return console.log(arr, "on", element.key, "is undefined"); | ||
if (!arr || !arr.length) return console.log(arr, "on", element.key, "is undefined"); | ||
while (active.key === arr[0]) { | ||
arr.shift(); | ||
if (!arr.length) | ||
break; | ||
if (!arr.length) break; | ||
active = active[arr[0]]; | ||
if (!active) | ||
return; | ||
if (!active) return; | ||
} | ||
@@ -73,17 +70,11 @@ return active; | ||
if ((0, import_utils.isFunction)(param)) { | ||
if (parent.state && param(parent, parent.state, parent.context)) | ||
return parent; | ||
else if (parent.parent) | ||
return parent.lookup(param); | ||
else | ||
return; | ||
if (parent.state && param(parent, parent.state, parent.context)) return parent; | ||
else if (parent.parent) return parent.lookup(param); | ||
else return; | ||
} | ||
if (el[param]) | ||
return el[param]; | ||
if (el[param]) return el[param]; | ||
while (parent.param !== param) { | ||
if (parent[param]) | ||
return parent[param]; | ||
if (parent[param]) return parent[param]; | ||
parent = parent.parent; | ||
if (!parent) | ||
return; | ||
if (!parent) return; | ||
} | ||
@@ -100,4 +91,3 @@ return parent; | ||
const childElem = el[v]; | ||
if (v === param) | ||
return childElem; | ||
if (v === param) return childElem; | ||
else if ((0, import_utils.isFunction)(param)) { | ||
@@ -110,4 +100,3 @@ const exec = param(childElem, childElem.state, childElem.context); | ||
const lookdown2 = (_a = childElem == null ? void 0 : childElem.lookdown) == null ? void 0 : _a.call(childElem, param); | ||
if (lookdown2) | ||
return lookdown2; | ||
if (lookdown2) return lookdown2; | ||
} | ||
@@ -123,8 +112,6 @@ } | ||
const childElem = el[v]; | ||
if (v === param) | ||
results.push(childElem); | ||
if (v === param) results.push(childElem); | ||
else if ((0, import_utils.isFunction)(param)) { | ||
const exec = param(childElem, childElem.state, childElem.context); | ||
if (childElem.state && exec) | ||
results.push(childElem); | ||
if (childElem.state && exec) results.push(childElem); | ||
} | ||
@@ -138,11 +125,8 @@ (_a = childElem == null ? void 0 : childElem.lookdownAll) == null ? void 0 : _a.call(childElem, param, results); | ||
const el = this; | ||
if (!((_a = el.node) == null ? void 0 : _a.style)) | ||
return; | ||
if (!((_a = el.node) == null ? void 0 : _a.style)) return; | ||
for (const param in params) { | ||
const value = params[param]; | ||
const childElem = el[param]; | ||
if ((0, import_utils.isObject)(value) && childElem) | ||
setNodeStyles.call(childElem, value); | ||
else | ||
el.node.style[param] = value; | ||
if ((0, import_utils.isObject)(value) && childElem) setNodeStyles.call(childElem, value); | ||
else el.node.style[param] = value; | ||
} | ||
@@ -154,6 +138,4 @@ return el; | ||
const beforeRemoveReturns = (0, import_event.triggerEventOn)("beforeRemove", element, opts); | ||
if (beforeRemoveReturns === false) | ||
return element; | ||
if ((0, import_utils.isFunction)(element.node.remove)) | ||
element.node.remove(); | ||
if (beforeRemoveReturns === false) return element; | ||
if ((0, import_utils.isFunction)(element.node.remove)) element.node.remove(); | ||
else if (!(0, import_utils.isProduction)()) { | ||
@@ -164,4 +146,3 @@ console.warn("This item cant be removed"); | ||
delete element.parent[element.key]; | ||
if (element.parent.__ref) | ||
element.parent.__ref.__children = (0, import_utils.removeValueFromArray)(element.parent.__ref.__children, element.key); | ||
if (element.parent.__ref) element.parent.__ref.__children = (0, import_utils.removeValueFromArray)(element.parent.__ref.__children, element.key); | ||
(0, import_event.triggerEventOn)("remove", element, opts); | ||
@@ -175,4 +156,3 @@ } | ||
const element = this; | ||
if (!param || !element.props) | ||
return; | ||
if (!param || !element.props) return; | ||
element.update({ props: param }, options); | ||
@@ -204,13 +184,10 @@ return element; | ||
keyList.forEach((v) => { | ||
if (excl.includes(v)) | ||
return; | ||
if (excl.includes(v)) return; | ||
const val = element[v]; | ||
if (v === "state") { | ||
if (element.__ref && !element.__ref.__hasRootState) | ||
return; | ||
if (element.__ref && !element.__ref.__hasRootState) return; | ||
const parsedVal = (0, import_utils.isFunction)(val && val.parse) ? val.parse() : val; | ||
obj[v] = (0, import_utils.isFunction)(parsedVal) ? parsedVal : JSON.parse(JSON.stringify(parsedVal || {})); | ||
} else if (v === "scope") { | ||
if (element.__ref && !element.__ref.__hasRootScope) | ||
return; | ||
if (element.__ref && !element.__ref.__hasRootScope) return; | ||
obj[v] = JSON.parse(JSON.stringify(val || {})); | ||
@@ -220,4 +197,3 @@ } else if (v === "props") { | ||
obj[v] = props; | ||
} else if ((0, import_utils.isDefined)(val) && Object.hasOwnProperty.call(element, v)) | ||
obj[v] = val; | ||
} else if ((0, import_utils.isDefined)(val) && Object.hasOwnProperty.call(element, v)) obj[v] = val; | ||
}); | ||
@@ -230,4 +206,3 @@ return obj; | ||
for (const v in obj) { | ||
if (excl.includes(v)) | ||
return; | ||
if (excl.includes(v)) return; | ||
if ((0, import_utils.isObjectLike)(obj[v])) { | ||
@@ -240,4 +215,3 @@ obj[v] = parseDeep.call(obj[v], excl); | ||
function verbose(...args) { | ||
if (ENV !== "test" && ENV !== "development") | ||
return; | ||
if (ENV !== "test" && ENV !== "development") return; | ||
const element = this; | ||
@@ -271,6 +245,4 @@ const { __ref: ref } = element; | ||
if (ENV === "test" || ENV === "development") { | ||
if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger) | ||
debugger; | ||
if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose) | ||
verbose.call(this); | ||
if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger) debugger; | ||
if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose) verbose.call(this); | ||
throw new Error(...params); | ||
@@ -291,4 +263,3 @@ } | ||
const { __children } = parent.__ref; | ||
if (!__children) | ||
return; | ||
if (!__children) return; | ||
const currentIndex = __children.indexOf(key); | ||
@@ -299,6 +270,4 @@ return parent[__children[currentIndex - 1]]; | ||
const element = this; | ||
if (!element.data) | ||
element.data = {}; | ||
if (!element.data.varCaches) | ||
element.data.varCaches = {}; | ||
if (!element.data) element.data = {}; | ||
if (!element.data.varCaches) element.data.varCaches = {}; | ||
const varCaches = element.data.varCaches; | ||
@@ -315,4 +284,3 @@ const changes = {}; | ||
changed: (cb) => { | ||
if (!changed) | ||
return; | ||
if (!changed) return; | ||
const returns = cb(changes, (0, import_utils.deepClone)(varCaches)); | ||
@@ -325,4 +293,3 @@ for (const key in changes) { | ||
timeout: (cb, timeout) => { | ||
if (!changed) | ||
return; | ||
if (!changed) return; | ||
const t = setTimeout(() => { | ||
@@ -329,0 +296,0 @@ cb(changes); |
@@ -57,5 +57,4 @@ "use strict"; | ||
}; | ||
if (element.context.methods) | ||
(options.strict ? import_utils.merge : import_utils.overwrite)(proto, element.context.methods); | ||
if (element.context.methods) (options.strict ? import_utils.merge : import_utils.overwrite)(proto, element.context.methods); | ||
Object.setPrototypeOf(element, proto); | ||
}; |
@@ -49,15 +49,11 @@ "use strict"; | ||
keyList.forEach((v) => { | ||
if (excl.includes(v)) | ||
return; | ||
if (excl.includes(v)) return; | ||
let val = element[v]; | ||
if (v === "state") { | ||
if (element.__ref && element.__ref.__hasRootState) | ||
return; | ||
if ((0, import_utils.isFunction)(val && val.parse)) | ||
val = val.parse(); | ||
if (element.__ref && element.__ref.__hasRootState) return; | ||
if ((0, import_utils.isFunction)(val && val.parse)) val = val.parse(); | ||
} else if (v === "props") { | ||
const { __element, update, ...props } = element[v]; | ||
obj[v] = props; | ||
} else if ((0, import_utils.isDefined)(val)) | ||
obj[v] = val; | ||
} else if ((0, import_utils.isDefined)(val)) obj[v] = val; | ||
}); | ||
@@ -70,4 +66,3 @@ return obj; | ||
for (const v in obj) { | ||
if (excl.includes(v)) | ||
return; | ||
if (excl.includes(v)) return; | ||
if ((0, import_utils.isObjectLike)(obj[v])) { | ||
@@ -107,6 +102,5 @@ obj[v] = parseDeep.call(obj[v], excl); | ||
const { __children } = parent.__ref; | ||
if (!__children) | ||
return; | ||
if (!__children) return; | ||
const currentIndex = __children.indexOf(key); | ||
return parent[__children[currentIndex - 1]]; | ||
}; |
@@ -31,13 +31,9 @@ "use strict"; | ||
const { __attr } = ref; | ||
if ((0, import_utils.isNot)("object")) | ||
(0, import_report.report)("HTMLInvalidAttr", params); | ||
if ((0, import_utils.isNot)("object")) (0, import_report.report)("HTMLInvalidAttr", params); | ||
if (params) { | ||
if (props.attr) | ||
(0, import_utils2.deepMerge)(params, props.attr); | ||
if (props.attr) (0, import_utils2.deepMerge)(params, props.attr); | ||
for (const attr2 in params) { | ||
const val = (0, import_utils.exec)(params[attr2], element); | ||
if (val !== false && !(0, import_utils.isUndefined)(val) && !(0, import_utils.isNull)(val) && node.setAttribute) | ||
node.setAttribute(attr2, val); | ||
else if (node.removeAttribute) | ||
node.removeAttribute(attr2); | ||
if (val !== false && !(0, import_utils.isUndefined)(val) && !(0, import_utils.isNull)(val) && node.setAttribute) node.setAttribute(attr2, val); | ||
else if (node.removeAttribute) node.removeAttribute(attr2); | ||
__attr[attr2] = val; | ||
@@ -44,0 +40,0 @@ } |
@@ -32,4 +32,3 @@ "use strict"; | ||
const { key } = element; | ||
if (element.class === true) | ||
element.class = key; | ||
if (element.class === true) element.class = key; | ||
else if (!element.class && typeof key === "string" && key.charAt(0) === "_" && key.charAt(1) !== "_") { | ||
@@ -43,6 +42,4 @@ element.class = key.slice(1); | ||
const param = obj[item]; | ||
if (typeof param === "boolean" && param) | ||
className += ` ${item}`; | ||
else if (typeof param === "string") | ||
className += ` ${param}`; | ||
if (typeof param === "boolean" && param) className += ` ${item}`; | ||
else if (typeof param === "string") className += ` ${param}`; | ||
else if (typeof param === "function") { | ||
@@ -55,14 +52,9 @@ className += ` ${(0, import_utils.exec)(param, element)}`; | ||
const classList = (params, element) => { | ||
if (!params) | ||
return; | ||
if (!params) return; | ||
const { key } = element; | ||
if (params === true) | ||
params = element.class = { key }; | ||
if ((0, import_utils.isString)(params)) | ||
params = element.class = { default: params }; | ||
if ((0, import_utils.isObject)(params)) | ||
params = classify(params, element); | ||
if (params === true) params = element.class = { key }; | ||
if ((0, import_utils.isString)(params)) params = element.class = { default: params }; | ||
if ((0, import_utils.isObject)(params)) params = classify(params, element); | ||
const className = params.replace(/\s+/g, " ").trim(); | ||
if (element.ref) | ||
element.ref.class = className; | ||
if (element.ref) element.ref.class = className; | ||
return className; | ||
@@ -69,0 +61,0 @@ }; |
@@ -33,6 +33,4 @@ "use strict"; | ||
const contentKey = ref.contentElementKey; | ||
if (!element[contentKey]) | ||
return; | ||
if (element[contentKey].update) | ||
element[contentKey].update(params, options); | ||
if (!element[contentKey]) return; | ||
if (element[contentKey].update) element[contentKey].update(params, options); | ||
}; | ||
@@ -43,12 +41,9 @@ const removeContent = function(el, opts = {}) { | ||
const contentElementKey = (0, import_utils.setContentKey)(element, opts); | ||
if (opts.contentElementKey !== "content") | ||
opts.contentElementKey = "content"; | ||
if (opts.contentElementKey !== "content") opts.contentElementKey = "content"; | ||
if (element[contentElementKey]) { | ||
if (element[contentElementKey].node && element.node) { | ||
if (element[contentElementKey].tag === "fragment") | ||
element.node.innerHTML = ""; | ||
if (element[contentElementKey].tag === "fragment") element.node.innerHTML = ""; | ||
else { | ||
const contentNode = element[contentElementKey].node; | ||
if (contentNode.parentNode === element.node) | ||
element.node.removeChild(element[contentElementKey].node); | ||
if (contentNode.parentNode === element.node) element.node.removeChild(element[contentElementKey].node); | ||
} | ||
@@ -58,6 +53,4 @@ } | ||
if (__cached && __cached[contentElementKey]) { | ||
if (__cached[contentElementKey].tag === "fragment") | ||
__cached[contentElementKey].parent.node.innerHTML = ""; | ||
else if (__cached[contentElementKey] && (0, import_utils.isFunction)(__cached[contentElementKey].remove)) | ||
__cached[contentElementKey].remove(); | ||
if (__cached[contentElementKey].tag === "fragment") __cached[contentElementKey].parent.node.innerHTML = ""; | ||
else if (__cached[contentElementKey] && (0, import_utils.isFunction)(__cached[contentElementKey].remove)) __cached[contentElementKey].remove(); | ||
} | ||
@@ -64,0 +57,0 @@ delete element[contentElementKey]; |
@@ -29,7 +29,5 @@ "use strict"; | ||
if (params) { | ||
if (element.props.data) | ||
(0, import_utils.deepMerge)(params, element.props.data); | ||
if (element.props.data) (0, import_utils.deepMerge)(params, element.props.data); | ||
if (params.showOnNode) { | ||
if (!(0, import_utils.isObject)(params)) | ||
(0, import_report.report)("HTMLInvalidData", params); | ||
if (!(0, import_utils.isObject)(params)) (0, import_report.report)("HTMLInvalidData", params); | ||
for (const dataset in params) { | ||
@@ -36,0 +34,0 @@ if (dataset !== "showOnNode") { |
@@ -31,6 +31,4 @@ "use strict"; | ||
if (prop !== __ref.__html) { | ||
if (node.nodeName === "SVG") | ||
node.textContent = prop; | ||
else | ||
node.innerHTML = prop; | ||
if (node.nodeName === "SVG") node.textContent = prop; | ||
else node.innerHTML = prop; | ||
__ref.__html = prop; | ||
@@ -37,0 +35,0 @@ } |
@@ -27,4 +27,3 @@ "use strict"; | ||
function scope(params, element, node) { | ||
if (!(0, import_utils.isObject)(params)) | ||
return; | ||
if (!(0, import_utils.isObject)(params)) return; | ||
for (const scopeItem in params) { | ||
@@ -31,0 +30,0 @@ const value = params[scopeItem]; |
@@ -31,6 +31,4 @@ "use strict"; | ||
for (const param in state2) { | ||
if (import_state.IGNORE_STATE_PARAMS.includes(param)) | ||
continue; | ||
if (!Object.hasOwnProperty.call(state2, param)) | ||
continue; | ||
if (import_state.IGNORE_STATE_PARAMS.includes(param)) continue; | ||
if (!Object.hasOwnProperty.call(state2, param)) continue; | ||
} | ||
@@ -37,0 +35,0 @@ } |
@@ -29,8 +29,6 @@ "use strict"; | ||
if (params) { | ||
if ((0, import_utils.isObject)(params)) | ||
(0, import_utils.map)(node.style, params, element); | ||
else | ||
(0, import_report.report)("HTMLInvalidStyles", params); | ||
if ((0, import_utils.isObject)(params)) (0, import_utils.map)(node.style, params, element); | ||
else (0, import_report.report)("HTMLInvalidStyles", params); | ||
} | ||
} | ||
var style_default = style; |
@@ -36,11 +36,8 @@ "use strict"; | ||
if (element.__text) { | ||
if (element.__text.text === prop) | ||
return; | ||
if (element.__text.text === prop) return; | ||
element.__text.text = prop; | ||
if (element.__text.node) | ||
element.__text.node.nodeValue = prop; | ||
} else | ||
(0, import_create.create)({ tag: "string", text: prop }, element, "__text"); | ||
if (element.__text.node) element.__text.node.nodeValue = prop; | ||
} else (0, import_create.create)({ tag: "string", text: prop }, element, "__text"); | ||
} | ||
} | ||
var text_default = text; |
@@ -40,8 +40,6 @@ "use strict"; | ||
isNewNode = true; | ||
if (!ref.__if) | ||
return element; | ||
if (!ref.__if) return element; | ||
if (tag === "shadow") { | ||
node = element.node = element.parent.node.attachShadow({ mode: "open" }); | ||
} else | ||
node = element.node = (0, import_render.cacheNode)(element); | ||
} else node = element.node = (0, import_render.cacheNode)(element); | ||
(0, import_event.triggerEventOn)("attachNode", element, options); | ||
@@ -51,4 +49,3 @@ } | ||
node.ref = element; | ||
if ((0, import_utils.isFunction)(node.setAttribute)) | ||
node.setAttribute("key", element.key); | ||
if ((0, import_utils.isFunction)(node.setAttribute)) node.setAttribute("key", element.key); | ||
} | ||
@@ -66,6 +63,4 @@ (0, import_iterate.throughExecProps)(element); | ||
const value = element[param]; | ||
if (!Object.hasOwnProperty.call(element, param)) | ||
continue; | ||
if ((0, import_utils.isUndefined)(value) || (0, import_methods.isMethod)(param, element) || (0, import_utils.isVariant)(param) || (0, import_utils.isObject)(import_mixins.REGISTRY[param])) | ||
continue; | ||
if (!Object.hasOwnProperty.call(element, param)) continue; | ||
if ((0, import_utils.isUndefined)(value) || (0, import_methods.isMethod)(param, element) || (0, import_utils.isVariant)(param) || (0, import_utils.isObject)(import_mixins.REGISTRY[param])) continue; | ||
const isElement = (0, import_applyParam.applyParam)(param, element, options); | ||
@@ -85,4 +80,3 @@ if (isElement) { | ||
}); | ||
} else | ||
await createAsync(); | ||
} else await createAsync(); | ||
} | ||
@@ -89,0 +83,0 @@ } |
@@ -31,12 +31,8 @@ "use strict"; | ||
const propsStack = ref.__props = (0, import_inherit.inheritParentProps)(element, parent); | ||
if ((0, import_utils.isObject)(props)) | ||
propsStack.push(props); | ||
else if (props === "inherit" && parent.props) | ||
propsStack.push(parent.props); | ||
else if (props) | ||
propsStack.push(props); | ||
if ((0, import_utils.isObject)(props)) propsStack.push(props); | ||
else if (props === "inherit" && parent.props) propsStack.push(parent.props); | ||
else if (props) propsStack.push(props); | ||
if ((0, import_utils.isArray)(ref.__extend)) { | ||
ref.__extend.forEach((extend) => { | ||
if (extend.props && extend.props !== props) | ||
propsStack.push(extend.props); | ||
if (extend.props && extend.props !== props) propsStack.push(extend.props); | ||
}); | ||
@@ -51,4 +47,3 @@ } | ||
props.forEach((v) => { | ||
if (import_ignore.IGNORE_PROPS_PARAMS.includes(v)) | ||
return; | ||
if (import_ignore.IGNORE_PROPS_PARAMS.includes(v)) return; | ||
let execProps; | ||
@@ -83,4 +78,3 @@ try { | ||
}; | ||
if (ref.__if) | ||
applyProps(); | ||
if (ref.__if) applyProps(); | ||
else { | ||
@@ -87,0 +81,0 @@ try { |
@@ -41,4 +41,3 @@ "use strict"; | ||
const inheritedStringExists = propsStack.filter((v) => v.inheritedString)[0]; | ||
if (inheritedStringExists) | ||
inheritedStringExists.inheritedString = matchParent; | ||
if (inheritedStringExists) inheritedStringExists.inheritedString = matchParent; | ||
else { | ||
@@ -51,5 +50,4 @@ propsStack = [].concat(objectizeStringProperty(matchParent), propsStack); | ||
} | ||
if (matchParentChildProps && !((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.ignoreChildProps)) | ||
propsStack.push(matchParentChildProps); | ||
if (matchParentChildProps && !((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.ignoreChildProps)) propsStack.push(matchParentChildProps); | ||
return propsStack; | ||
}; |
@@ -30,9 +30,6 @@ "use strict"; | ||
const parentProps = (0, import_inherit.inheritParentProps)(element, parent); | ||
if (parentProps.length) | ||
propsStack = __ref.__props = [].concat(parentProps, propsStack); | ||
if (newProps) | ||
propsStack = __ref.__props = [].concat(newProps, propsStack); | ||
if (propsStack) | ||
(0, import_create.syncProps)(propsStack, element); | ||
if (parentProps.length) propsStack = __ref.__props = [].concat(parentProps, propsStack); | ||
if (newProps) propsStack = __ref.__props = [].concat(newProps, propsStack); | ||
if (propsStack) (0, import_create.syncProps)(propsStack, element); | ||
return element; | ||
}; |
@@ -34,4 +34,3 @@ "use strict"; | ||
const resetElement = async (params, element, options) => { | ||
if (!options.preventRemove) | ||
(0, import_content.removeContent)(element, options); | ||
if (!options.preventRemove) (0, import_content.removeContent)(element, options); | ||
const { __ref: ref } = element; | ||
@@ -62,14 +61,10 @@ await (0, import_create.create)(params, element, ref.contentElementKey || "content", { | ||
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection; | ||
if (options.preventContentUpdate === true && !hasCollection) | ||
return; | ||
if (options.preventContentUpdate === true && !hasCollection) return; | ||
if (ref.__noCollectionDifference || __contentRef && __contentRef.__cached && (0, import_utils.deepContains)(params, content)) { | ||
if (!options.preventBeforeUpdateListener && !options.preventListeners) { | ||
const beforeUpdateReturns = await (0, import_event.triggerEventOnUpdate)("beforeUpdate", params, element, options); | ||
if (beforeUpdateReturns === false) | ||
return element; | ||
if (beforeUpdateReturns === false) return element; | ||
} | ||
if (content == null ? void 0 : content.update) | ||
content.update(); | ||
if (!options.preventUpdateListener) | ||
await (0, import_event.triggerEventOn)("update", element, options); | ||
if (content == null ? void 0 : content.update) content.update(); | ||
if (!options.preventUpdateListener) await (0, import_event.triggerEventOn)("update", element, options); | ||
return; | ||
@@ -79,4 +74,3 @@ } | ||
let { childExtend, props } = params; | ||
if (!props) | ||
props = params.props = {}; | ||
if (!props) props = params.props = {}; | ||
if (!childExtend && element.childExtend) { | ||
@@ -97,4 +91,3 @@ params.childExtend = element.childExtend; | ||
}); | ||
} else | ||
await resetElement(params, element, options); | ||
} else await resetElement(params, element, options); | ||
} | ||
@@ -101,0 +94,0 @@ return element; |
@@ -55,13 +55,8 @@ "use strict"; | ||
let ref = element.__ref; | ||
if (!ref) | ||
ref = element.__ref = {}; | ||
if (!ref) ref = element.__ref = {}; | ||
const [snapshotOnCallee, calleeElement, snapshotHasUpdated] = captureSnapshot(element, options); | ||
if (snapshotHasUpdated) | ||
return; | ||
if (!options.preventListeners) | ||
await (0, import_event.triggerEventOnUpdate)("startUpdate", params, element, options); | ||
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element) | ||
return; | ||
if (!excludes) | ||
(0, import_utils.merge)(options, UPDATE_DEFAULT_OPTIONS); | ||
if (snapshotHasUpdated) return; | ||
if (!options.preventListeners) await (0, import_event.triggerEventOnUpdate)("startUpdate", params, element, options); | ||
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element) return; | ||
if (!excludes) (0, import_utils.merge)(options, UPDATE_DEFAULT_OPTIONS); | ||
if ((0, import_utils.isString)(params) || (0, import_utils.isNumber)(params)) { | ||
@@ -71,7 +66,5 @@ params = { text: params }; | ||
const inheritState = await inheritStateUpdates(element, options); | ||
if (inheritState === false) | ||
return; | ||
if (inheritState === false) return; | ||
const ifFails = checkIfOnUpdate(element, parent, options); | ||
if (ifFails) | ||
return; | ||
if (ifFails) return; | ||
if (ref.__if && !options.preventPropsUpdate) { | ||
@@ -81,9 +74,7 @@ const hasParentProps = parent.props && (parent.props[key] || parent.props.childProps); | ||
const props = params.props || hasParentProps || hasFunctionInProps.length; | ||
if (props) | ||
(0, import_props.updateProps)(props, element, parent); | ||
if (props) (0, import_props.updateProps)(props, element, parent); | ||
} | ||
if (!options.preventBeforeUpdateListener && !options.preventListeners) { | ||
const beforeUpdateReturns = await (0, import_event.triggerEventOnUpdate)("beforeUpdate", params, element, options); | ||
if (beforeUpdateReturns === false) | ||
return element; | ||
if (beforeUpdateReturns === false) return element; | ||
} | ||
@@ -97,4 +88,3 @@ (0, import_utils.overwriteDeep)(element, params, { exclude: import_utils2.METHODS_EXL }); | ||
} | ||
if (!ref.__if) | ||
return false; | ||
if (!ref.__if) return false; | ||
if (!node) { | ||
@@ -114,20 +104,14 @@ return; | ||
if (preventUpdateAfter) { | ||
if ((0, import_utils.isNumber)(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount) | ||
return; | ||
else if (options.preventUpdateAfterCount === void 0) | ||
options.preventUpdateAfterCount = 1; | ||
else | ||
options.preventUpdateAfterCount++; | ||
if ((0, import_utils.isNumber)(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount) return; | ||
else if (options.preventUpdateAfterCount === void 0) options.preventUpdateAfterCount = 1; | ||
else options.preventUpdateAfterCount++; | ||
} | ||
for (const param in element) { | ||
const prop = element[param]; | ||
if (!Object.hasOwnProperty.call(element, param)) | ||
continue; | ||
if (!Object.hasOwnProperty.call(element, param)) continue; | ||
const isInPreventUpdate = (0, import_utils.isArray)(preventUpdate) && preventUpdate.includes(param); | ||
const isInPreventDefineUpdate = (0, import_utils.isArray)(preventDefineUpdate) && preventDefineUpdate.includes(param); | ||
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection; | ||
if ((0, import_utils.isUndefined)(prop) || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || (0, import_methods.isMethod)(param, element) || (0, import_utils.isObject)(import_mixins.REGISTRY[param]) || (0, import_utils.isVariant)(param)) | ||
continue; | ||
if (preventStateUpdate === "once") | ||
options.preventStateUpdate = false; | ||
if ((0, import_utils.isUndefined)(prop) || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || (0, import_methods.isMethod)(param, element) || (0, import_utils.isObject)(import_mixins.REGISTRY[param]) || (0, import_utils.isVariant)(param)) continue; | ||
if (preventStateUpdate === "once") options.preventStateUpdate = false; | ||
const isElement = (0, import_applyParam.applyParam)(param, element, options); | ||
@@ -137,4 +121,3 @@ if (isElement) { | ||
const canUpdate = (0, import_utils.isObject)(prop) && !hasDefine && !hasContextDefine && !preventRecursive; | ||
if (!canUpdate) | ||
continue; | ||
if (!canUpdate) continue; | ||
const lazyLoad = element.props.lazyLoad || options.lazyLoad; | ||
@@ -157,4 +140,3 @@ if (options.onEachUpdate) { | ||
} | ||
if (!preventUpdateListener) | ||
(0, import_event.triggerEventOn)("update", element, options); | ||
if (!preventUpdateListener) (0, import_event.triggerEventOn)("update", element, options); | ||
}; | ||
@@ -178,4 +160,3 @@ const captureSnapshot = (element, options) => { | ||
var _a, _b, _c; | ||
if (!(0, import_utils.isFunction)(element.if) && !(0, import_utils.isFunction)((_a = element.props) == null ? void 0 : _a.if) || !parent) | ||
return; | ||
if (!(0, import_utils.isFunction)(element.if) && !(0, import_utils.isFunction)((_a = element.props) == null ? void 0 : _a.if) || !parent) return; | ||
const ref = element.__ref; | ||
@@ -205,4 +186,3 @@ const ifPassed = (element.if || ((_b = element.props) == null ? void 0 : _b.if))(element, element.state, element.context, options); | ||
element.removeContent(); | ||
} else if ((_c = element[contentKey]) == null ? void 0 : _c.parseDeep) | ||
element[contentKey] = element[contentKey].parseDeep(); | ||
} else if ((_c = element[contentKey]) == null ? void 0 : _c.parseDeep) element[contentKey] = element[contentKey].parseDeep(); | ||
const previousElement = element.previousElement(); | ||
@@ -236,4 +216,3 @@ const previousNode = previousElement == null ? void 0 : previousElement.node; | ||
const { preventUpdateTriggerStateUpdate, isHoisted, execStateFunction } = options; | ||
if (preventUpdateTriggerStateUpdate) | ||
return; | ||
if (preventUpdateTriggerStateUpdate) return; | ||
if (!stateKey && !ref.__hasRootState) { | ||
@@ -250,8 +229,6 @@ element.state = parent && parent.state || {}; | ||
const keyInParentState = (0, import_state.findInheritedState)(element, element.parent); | ||
if (!keyInParentState || options.preventInheritedStateUpdate) | ||
return; | ||
if (!keyInParentState || options.preventInheritedStateUpdate) return; | ||
if (!options.preventBeforeStateUpdateListener && !options.preventListeners) { | ||
const initStateReturns = await (0, import_event.triggerEventOnUpdate)("beforeStateUpdate", keyInParentState, element, options); | ||
if (initStateReturns === false) | ||
return element; | ||
if (initStateReturns === false) return element; | ||
} | ||
@@ -268,4 +245,3 @@ const newState = createStateUpdate(element, parent, options); | ||
for (const child in __stateChildren) { | ||
if (newState[child]) | ||
newState.__children[child] = __stateChildren[child]; | ||
if (newState[child]) newState.__children[child] = __stateChildren[child]; | ||
Object.getPrototypeOf(__stateChildren[child]).parent = newState; | ||
@@ -272,0 +248,0 @@ } |
@@ -35,4 +35,3 @@ "use strict"; | ||
const hasContextDefine = context && context.define && context.define[param]; | ||
if (!ref.__if) | ||
return; | ||
if (!ref.__if) return; | ||
const hasOnlyUpdate = onlyUpdate ? onlyUpdate === param || element.lookup(onlyUpdate) : true; | ||
@@ -39,0 +38,0 @@ if (isGlobalTransformer && !hasContextDefine && hasOnlyUpdate) { |
@@ -49,4 +49,3 @@ "use strict"; | ||
let variantElement = element[variant]; | ||
if (!variantElement) | ||
return; | ||
if (!variantElement) return; | ||
const props = (0, import_utils.isObject)(variantProps) ? variantProps : {}; | ||
@@ -66,4 +65,3 @@ if ((0, import_utils.isString)(variantElement)) { | ||
const { props } = element; | ||
if (!(0, import_utils.hasVariantProp)(element)) | ||
return element; | ||
if (!(0, import_utils.hasVariantProp)(element)) return element; | ||
const { variant } = props; | ||
@@ -75,6 +73,5 @@ overwriteVariant(element, `.${variant}`); | ||
const variantElementProps = props[slicedVariantElementKey]; | ||
if (variantElementProps) | ||
overwriteVariant(element, variant2, variantElementProps); | ||
if (variantElementProps) overwriteVariant(element, variant2, variantElementProps); | ||
}); | ||
return element; | ||
}; |
@@ -72,11 +72,7 @@ "use strict"; | ||
const flattenExtend = (extend, stack, context) => { | ||
if (!extend) | ||
return stack; | ||
if ((0, import_utils.isArray)(extend)) | ||
return extractArrayExtend(extend, stack, context); | ||
if ((0, import_utils.isString)(extend)) | ||
extend = fallbackStringExtend(extend, context); | ||
if (!extend) return stack; | ||
if ((0, import_utils.isArray)(extend)) return extractArrayExtend(extend, stack, context); | ||
if ((0, import_utils.isString)(extend)) extend = fallbackStringExtend(extend, context); | ||
stack.push(extend); | ||
if (extend.extend) | ||
deepExtend(extend, stack, context); | ||
if (extend.extend) deepExtend(extend, stack, context); | ||
return stack; | ||
@@ -86,4 +82,3 @@ }; | ||
for (const e in extend) { | ||
if (["parent", "node", "__element"].indexOf(e) > -1) | ||
continue; | ||
if (["parent", "node", "__element"].indexOf(e) > -1) continue; | ||
const elementProp = element[e]; | ||
@@ -117,6 +112,4 @@ const extendProp = extend[e]; | ||
const pageExists = PAGES && extend.startsWith("/") && PAGES[extend]; | ||
if (componentExists) | ||
return componentExists; | ||
else if (pageExists) | ||
return pageExists; | ||
if (componentExists) return componentExists; | ||
else if (pageExists) return pageExists; | ||
else { | ||
@@ -135,6 +128,4 @@ if (options.verbose && (ENV === "test" || ENV === "development")) { | ||
const getExtendStack = (extend, context) => { | ||
if (!extend) | ||
return []; | ||
if (extend.__hash) | ||
return getHashedExtend(extend) || []; | ||
if (!extend) return []; | ||
if (extend.__hash) return getHashedExtend(extend) || []; | ||
const stack = flattenExtend(extend, [], context); | ||
@@ -141,0 +132,0 @@ return getExtendStackRegistry(extend, stack); |
@@ -99,4 +99,3 @@ "use strict"; | ||
for (const e in extend) { | ||
if (exclude.includes(e)) | ||
continue; | ||
if (exclude.includes(e)) continue; | ||
const elementProp = element[e]; | ||
@@ -115,4 +114,3 @@ const extendProp = extend[e]; | ||
for (const e in obj) { | ||
if (exclude.includes(e)) | ||
continue; | ||
if (exclude.includes(e)) continue; | ||
o[e] = obj[e]; | ||
@@ -127,4 +125,3 @@ } | ||
for (const e in params) { | ||
if (e === "props" || e === "state" || e === "__ref") | ||
continue; | ||
if (e === "props" || e === "state" || e === "__ref") continue; | ||
const elementProp = element[e]; | ||
@@ -136,4 +133,3 @@ const paramsProp = params[e]; | ||
} | ||
if (options.cleanExec) | ||
delete __exec[e]; | ||
if (options.cleanExec) delete __exec[e]; | ||
} | ||
@@ -144,4 +140,3 @@ return changes; | ||
for (const e in params) { | ||
if (exclude.includes(e)) | ||
continue; | ||
if (exclude.includes(e)) continue; | ||
obj[e] = params[e]; | ||
@@ -153,4 +148,3 @@ } | ||
for (const e in params) { | ||
if (exclude.includes(e)) | ||
continue; | ||
if (exclude.includes(e)) continue; | ||
const objProp = obj[e]; | ||
@@ -167,4 +161,3 @@ const paramsProp = params[e]; | ||
const mergeIfExisted = (a, b) => { | ||
if ((0, import_utils.isObjectLike)(a) && (0, import_utils.isObjectLike)(b)) | ||
return deepMerge(a, b); | ||
if ((0, import_utils.isObjectLike)(a) && (0, import_utils.isObjectLike)(b)) return deepMerge(a, b); | ||
return a || b; | ||
@@ -182,6 +175,5 @@ }; | ||
const extendOfExtend = objectized[prop]; | ||
if (extendOfExtend) | ||
flattenRecursive(extendOfExtend, prop, stack); | ||
if (extendOfExtend) flattenRecursive(extendOfExtend, prop, stack); | ||
delete objectized[prop]; | ||
return stack; | ||
}; |
@@ -39,20 +39,11 @@ "use strict"; | ||
const { __ref: ref2 } = element; | ||
if (!ref2.__cached) | ||
ref2.__cached = {}; | ||
if (!ref2.__defineCache) | ||
ref2.__defineCache = {}; | ||
if (!ref2.__exec) | ||
ref2.__exec = {}; | ||
if (!ref2.__execProps) | ||
ref2.__execProps = {}; | ||
if (!ref2.__class) | ||
ref2.__class = {}; | ||
if (!ref2.__classNames) | ||
ref2.__classNames = {}; | ||
if (!ref2.__attr) | ||
ref2.__attr = {}; | ||
if (!ref2.__changes) | ||
ref2.__changes = []; | ||
if (!ref2.__children) | ||
ref2.__children = []; | ||
if (!ref2.__cached) ref2.__cached = {}; | ||
if (!ref2.__defineCache) ref2.__defineCache = {}; | ||
if (!ref2.__exec) ref2.__exec = {}; | ||
if (!ref2.__execProps) ref2.__execProps = {}; | ||
if (!ref2.__class) ref2.__class = {}; | ||
if (!ref2.__classNames) ref2.__classNames = {}; | ||
if (!ref2.__attr) ref2.__attr = {}; | ||
if (!ref2.__changes) ref2.__changes = []; | ||
if (!ref2.__children) ref2.__children = []; | ||
} | ||
@@ -66,6 +57,4 @@ (0, import_set.addMethods)(element, parent, options); | ||
delete ref.__if; | ||
} else | ||
ref.__if = true; | ||
} else | ||
ref.__if = true; | ||
} else ref.__if = true; | ||
} else ref.__if = true; | ||
if (element.node && ref.__if) { | ||
@@ -81,4 +70,3 @@ parent[key || element.key] = element; | ||
const prop = element[param]; | ||
if ((0, import_utils.isUndefined)(prop) || (0, import_methods.isMethod)(param, element) || (0, import_utils.isObject)(import_mixins.REGISTRY[param]) || (0, import__2.isVariant)(param)) | ||
continue; | ||
if ((0, import_utils.isUndefined)(prop) || (0, import_methods.isMethod)(param, element) || (0, import_utils.isObject)(import_mixins.REGISTRY[param]) || (0, import__2.isVariant)(param)) continue; | ||
const hasDefine = element.define && element.define[param]; | ||
@@ -101,5 +89,4 @@ const contextHasDefine = element.context && element.context.define && element.context.define[param]; | ||
} | ||
if (!options.keepRef) | ||
delete element.__ref; | ||
if (!options.keepRef) delete element.__ref; | ||
return element; | ||
}; |
@@ -35,8 +35,6 @@ "use strict"; | ||
const originalEventRetunrs = origEvent(...args); | ||
if (originalEventRetunrs !== false) | ||
funcFromProps(...args); | ||
if (originalEventRetunrs !== false) funcFromProps(...args); | ||
}; | ||
} else | ||
on[eventName] = funcFromProps; | ||
} else on[eventName] = funcFromProps; | ||
}); | ||
}; |
@@ -62,8 +62,6 @@ import { createNode } from "./node.js"; | ||
await createState(element, parent); | ||
if (element.scope === "state") | ||
element.scope = element.state; | ||
if (element.scope === "state") element.scope = element.state; | ||
createIfConditionFlag(element, parent); | ||
createProps(element, parent, options); | ||
if (element.scope === "props" || element.scope === true) | ||
element.scope = element.props; | ||
if (element.scope === "props" || element.scope === true) element.scope = element.props; | ||
createIfConditionFlag(element, parent); | ||
@@ -75,4 +73,3 @@ if (element.node && ref.__if) { | ||
const onInit = await triggerEventOn("init", element, options); | ||
if (onInit === false) | ||
return element; | ||
if (onInit === false) return element; | ||
triggerEventOn("beforeClassAssign", element, options); | ||
@@ -93,3 +90,3 @@ assignKeyAsClassname(element); | ||
} | ||
if (isString(key) && key.slice(0, 2 === "__")) { | ||
if (isString(key) && key.slice(0, false)) { | ||
if (ENV === "test" || ENV === "development") { | ||
@@ -99,6 +96,4 @@ console.warn(key, "seems like to be in __ref"); | ||
} | ||
if (element === null) | ||
return; | ||
if (element === true) | ||
return { text: true }; | ||
if (element === null) return; | ||
if (element === true) return { text: true }; | ||
if (element.__hash) { | ||
@@ -112,6 +107,4 @@ return { extend: element }; | ||
if (options.syntaxv3 || element.props && element.props.syntaxv3 || parent && parent.props && parent.props.syntaxv3) { | ||
if (element.props) | ||
element.props.syntaxv3 = true; | ||
else | ||
element.syntaxv3 = true; | ||
if (element.props) element.props.syntaxv3 = true; | ||
else element.syntaxv3 = true; | ||
return createValidDomqlObjectFromSugar(element, parent, key, options); | ||
@@ -127,4 +120,3 @@ } else if (checkIfKeyIsComponent(key)) { | ||
const redefineParent = (element, parent, key, options) => { | ||
if (!parent) | ||
return ROOT; | ||
if (!parent) return ROOT; | ||
if (isNode(parent)) { | ||
@@ -147,6 +139,4 @@ const parentNodeWrapper = { key: ":root", node: parent }; | ||
const addRef = (element, parent) => { | ||
if (element.__ref) | ||
element.__ref.origin = element; | ||
else | ||
element.__ref = { origin: element }; | ||
if (element.__ref) element.__ref.origin = element; | ||
else element.__ref = { origin: element }; | ||
return element.__ref; | ||
@@ -157,9 +147,7 @@ }; | ||
registry.defaultOptions = options; | ||
if (options.ignoreChildExtend) | ||
delete options.ignoreChildExtend; | ||
if (options.ignoreChildExtend) delete options.ignoreChildExtend; | ||
} | ||
}; | ||
const addElementIntoParentChildren = (element, parent) => { | ||
if (parent.__ref && parent.__ref.__children) | ||
parent.__ref.__children.push(element.key); | ||
if (parent.__ref && parent.__ref.__children) parent.__ref.__children.push(element.key); | ||
}; | ||
@@ -170,4 +158,3 @@ const visitedElements = /* @__PURE__ */ new WeakMap(); | ||
if (visitedElements.has(element)) { | ||
if (ENV === "test" || ENV === "development") | ||
console.warn("Cyclic rendering detected:", element.__ref.path); | ||
if (ENV === "test" || ENV === "development") console.warn("Cyclic rendering detected:", element.__ref.path); | ||
} | ||
@@ -178,4 +165,3 @@ visitedElements.set(element, true); | ||
const isInfiniteLoopDetected = detectInfiniteLoop(ref.path); | ||
if (ref.__uniqId || isInfiniteLoopDetected) | ||
return; | ||
if (ref.__uniqId || isInfiniteLoopDetected) return; | ||
await createNode(element, options); | ||
@@ -191,6 +177,4 @@ ref.__uniqId = Math.random(); | ||
const path = ref.path; | ||
if (path.includes("ComponentsGrid")) | ||
path.splice(0, path.indexOf("ComponentsGrid") + 2); | ||
if (path.includes("demoComponent")) | ||
path.splice(0, path.indexOf("demoComponent") + 1); | ||
if (path.includes("ComponentsGrid")) path.splice(0, path.indexOf("ComponentsGrid") + 2); | ||
if (path.includes("demoComponent")) path.splice(0, path.indexOf("demoComponent") + 1); | ||
const isDemoComponent = (_b = (_a = element.lookup((el) => el.state.key)) == null ? void 0 : _a.state) == null ? void 0 : _b.key; | ||
@@ -200,6 +184,4 @@ element.warn("Error happened in:", isDemoComponent ? isDemoComponent + " " : "" + path.join(".")); | ||
element.error(e, options); | ||
if ((_c = element.on) == null ? void 0 : _c.error) | ||
element.on.error(e, element, element.state, element.context, options); | ||
if ((_d = element.props) == null ? void 0 : _d.onError) | ||
element.props.onError(e, element, element.state, element.context, options); | ||
if ((_c = element.on) == null ? void 0 : _c.error) element.on.error(e, element, element.state, element.context, options); | ||
if ((_d = element.props) == null ? void 0 : _d.onError) element.props.onError(e, element, element.state, element.context, options); | ||
} | ||
@@ -231,11 +213,8 @@ } | ||
const forcedOptionsContext = options.context && !ROOT.context && !element.context; | ||
if (forcedOptionsContext) | ||
ROOT.context = options.context; | ||
if (!element.context) | ||
element.context = parent.context || options.context || ROOT.context; | ||
if (forcedOptionsContext) ROOT.context = options.context; | ||
if (!element.context) element.context = parent.context || options.context || ROOT.context; | ||
}; | ||
const createScope = (element, parent) => { | ||
const { __ref: ref } = element; | ||
if (!element.scope) | ||
element.scope = parent.scope || ref.root.scope || {}; | ||
if (!element.scope) element.scope = parent.scope || ref.root.scope || {}; | ||
}; | ||
@@ -246,4 +225,3 @@ const createIfConditionFlag = (element, parent) => { | ||
delete ref.__if; | ||
} else | ||
ref.__if = true; | ||
} else ref.__if = true; | ||
}; | ||
@@ -253,31 +231,17 @@ const addCaching = (element, parent) => { | ||
let { __ref: parentRef } = parent; | ||
if (!element.transform) | ||
element.transform = {}; | ||
if (!ref.__cached) | ||
ref.__cached = {}; | ||
if (!ref.__defineCache) | ||
ref.__defineCache = {}; | ||
if (!ref.__exec) | ||
ref.__exec = {}; | ||
if (!ref.__execProps) | ||
ref.__execProps = {}; | ||
if (!ref.__class) | ||
ref.__class = {}; | ||
if (!ref.__classNames) | ||
ref.__classNames = {}; | ||
if (!ref.__attr) | ||
ref.__attr = {}; | ||
if (!ref.__changes) | ||
ref.__changes = []; | ||
if (!ref.__children) | ||
ref.__children = []; | ||
if (checkIfKeyIsComponent(key)) | ||
ref.__componentKey = key.split("_")[0].split(".")[0].split("+")[0]; | ||
if (!element.transform) element.transform = {}; | ||
if (!ref.__cached) ref.__cached = {}; | ||
if (!ref.__defineCache) ref.__defineCache = {}; | ||
if (!ref.__exec) ref.__exec = {}; | ||
if (!ref.__execProps) ref.__execProps = {}; | ||
if (!ref.__class) ref.__class = {}; | ||
if (!ref.__classNames) ref.__classNames = {}; | ||
if (!ref.__attr) ref.__attr = {}; | ||
if (!ref.__changes) ref.__changes = []; | ||
if (!ref.__children) ref.__children = []; | ||
if (checkIfKeyIsComponent(key)) ref.__componentKey = key.split("_")[0].split(".")[0].split("+")[0]; | ||
const hasRoot = parent && parent.key === ":root"; | ||
if (!ref.root) | ||
ref.root = hasRoot ? element : parentRef.root; | ||
if (!parentRef) | ||
parentRef = parent.ref = {}; | ||
if (!parentRef.path) | ||
parentRef.path = []; | ||
if (!ref.root) ref.root = hasRoot ? element : parentRef.root; | ||
if (!parentRef) parentRef = parent.ref = {}; | ||
if (!parentRef.path) parentRef.path = []; | ||
ref.path = parentRef.path.concat(element.key); | ||
@@ -292,13 +256,10 @@ }; | ||
createState(element, parent); | ||
if (element.scope === "state") | ||
element.scope = element.state; | ||
if (element.scope === "state") element.scope = element.state; | ||
createIfConditionFlag(element, parent); | ||
createProps(element, parent, options); | ||
if (element.scope === "props" || element.scope === true) | ||
element.scope = element.props; | ||
if (element.scope === "props" || element.scope === true) element.scope = element.props; | ||
if (element.node && ref.__if) { | ||
parent[key || element.key] = element; | ||
} | ||
if (!element.props) | ||
element.props = {}; | ||
if (!element.props) element.props = {}; | ||
applyVariant(element, parent); | ||
@@ -311,4 +272,3 @@ addElementIntoParentChildren(element, parent); | ||
for (const k in element) { | ||
if (isUndefined(element[k]) || isMethod(k, element) || isObject((registry.default || registry)[k]) || isVariant(k)) | ||
continue; | ||
if (isUndefined(element[k]) || isMethod(k, element) || isObject((registry.default || registry)[k]) || isVariant(k)) continue; | ||
const hasDefine = element.define && element.define[k]; | ||
@@ -338,6 +298,4 @@ const contextHasDefine = element.context && element.context.define && element.context.define[k]; | ||
props.display = "none"; | ||
if (props[key]) | ||
props[key].display = props.display; | ||
else | ||
props[key] = { display: props.display || "block" }; | ||
if (props[key]) props[key].display = props.display; | ||
else props[key] = { display: props.display || "block" }; | ||
return element; | ||
@@ -344,0 +302,0 @@ } else { |
@@ -8,4 +8,3 @@ import { report } from "@domql/report"; | ||
report("OverwriteToBuiltin", param); | ||
} else | ||
REGISTRY[param] = params[param]; | ||
} else REGISTRY[param] = params[param]; | ||
} | ||
@@ -12,0 +11,0 @@ }; |
@@ -12,4 +12,3 @@ import { isFunction, exec } from "@domql/utils"; | ||
const applyExtend = (element, parent, options = {}) => { | ||
if (isFunction(element)) | ||
element = exec(element, parent); | ||
if (isFunction(element)) element = exec(element, parent); | ||
const { props, __ref } = element; | ||
@@ -21,4 +20,3 @@ let extend = (props == null ? void 0 : props.extends) || element.extends || element.extend; | ||
const extendStack = getExtendStack(extend, context); | ||
if (ENV !== "test" || ENV !== "development") | ||
delete element.extend; | ||
if (ENV !== "test" || ENV !== "development") delete element.extend; | ||
let childExtendStack = []; | ||
@@ -49,4 +47,3 @@ if (parent) { | ||
stack = childExtendStack; | ||
} else if (!context.defaultExtends) | ||
return element; | ||
} else if (!context.defaultExtends) return element; | ||
if (context.defaultExtends) { | ||
@@ -60,4 +57,3 @@ if (!mainExtend) { | ||
} | ||
if (__ref) | ||
__ref.__extend = stack; | ||
if (__ref) __ref.__extend = stack; | ||
let mergedExtend = cloneAndMergeArrayExtend(stack); | ||
@@ -64,0 +60,0 @@ const COMPONENTS = context && context.components || options.components; |
@@ -16,4 +16,3 @@ import { | ||
for (const param in element) { | ||
if (exclude[param]) | ||
continue; | ||
if (exclude[param]) continue; | ||
const prop = element[param]; | ||
@@ -32,4 +31,3 @@ if (isFunction(prop) && !isMethod(param, element) && !isVariant(param)) { | ||
const isDefinedParam = ref.__defineCache[param]; | ||
if (isDefinedParam) | ||
continue; | ||
if (isDefinedParam) continue; | ||
const newExec = ref.__exec[param](element, element.state, element.context); | ||
@@ -69,6 +67,4 @@ const execReturnsString = isString(newExec) || isNumber(newExec); | ||
const hasGlobalDefine = context && isObject(context.define); | ||
if (isObject(define)) | ||
defineObj = { ...define }; | ||
if (hasGlobalDefine) | ||
defineObj = { ...defineObj, ...context.define }; | ||
if (isObject(define)) defineObj = { ...define }; | ||
if (hasGlobalDefine) defineObj = { ...defineObj, ...context.define }; | ||
for (const param in defineObj) { | ||
@@ -85,4 +81,3 @@ let elementProp = element[param]; | ||
const execParam = defineObj[param](elementProp, element, element.state, element.context); | ||
if (execParam) | ||
element[param] = execParam; | ||
if (execParam) element[param] = execParam; | ||
} | ||
@@ -95,14 +90,10 @@ return element; | ||
let obj = {}; | ||
if (isObject(define)) | ||
obj = { ...define }; | ||
if (isObject(context && context.define)) | ||
obj = { ...obj, ...context.define }; | ||
if (isObject(define)) obj = { ...define }; | ||
if (isObject(context && context.define)) obj = { ...obj, ...context.define }; | ||
for (const param in obj) { | ||
const execParam = ref.__exec[param]; | ||
if (execParam) | ||
ref.__defineCache[param] = execParam(element, element.state, element.context); | ||
if (execParam) ref.__defineCache[param] = execParam(element, element.state, element.context); | ||
const cached = exec(ref.__defineCache[param], element); | ||
const newExecParam = obj[param](cached, element, element.state, element.context); | ||
if (newExecParam) | ||
element[param] = newExecParam; | ||
if (newExecParam) element[param] = newExecParam; | ||
} | ||
@@ -109,0 +100,0 @@ return changes; |
@@ -10,11 +10,8 @@ import { triggerEventOn } from "@domql/event"; | ||
let active = TREE[arr[0]]; | ||
if (!arr || !arr.length) | ||
return console.log(arr, "on", element.key, "is undefined"); | ||
if (!arr || !arr.length) return console.log(arr, "on", element.key, "is undefined"); | ||
while (active.key === arr[0]) { | ||
arr.shift(); | ||
if (!arr.length) | ||
break; | ||
if (!arr.length) break; | ||
active = active[arr[0]]; | ||
if (!active) | ||
return; | ||
if (!active) return; | ||
} | ||
@@ -27,17 +24,11 @@ return active; | ||
if (isFunction(param)) { | ||
if (parent.state && param(parent, parent.state, parent.context)) | ||
return parent; | ||
else if (parent.parent) | ||
return parent.lookup(param); | ||
else | ||
return; | ||
if (parent.state && param(parent, parent.state, parent.context)) return parent; | ||
else if (parent.parent) return parent.lookup(param); | ||
else return; | ||
} | ||
if (el[param]) | ||
return el[param]; | ||
if (el[param]) return el[param]; | ||
while (parent.param !== param) { | ||
if (parent[param]) | ||
return parent[param]; | ||
if (parent[param]) return parent[param]; | ||
parent = parent.parent; | ||
if (!parent) | ||
return; | ||
if (!parent) return; | ||
} | ||
@@ -54,4 +45,3 @@ return parent; | ||
const childElem = el[v]; | ||
if (v === param) | ||
return childElem; | ||
if (v === param) return childElem; | ||
else if (isFunction(param)) { | ||
@@ -64,4 +54,3 @@ const exec = param(childElem, childElem.state, childElem.context); | ||
const lookdown2 = (_a = childElem == null ? void 0 : childElem.lookdown) == null ? void 0 : _a.call(childElem, param); | ||
if (lookdown2) | ||
return lookdown2; | ||
if (lookdown2) return lookdown2; | ||
} | ||
@@ -77,8 +66,6 @@ } | ||
const childElem = el[v]; | ||
if (v === param) | ||
results.push(childElem); | ||
if (v === param) results.push(childElem); | ||
else if (isFunction(param)) { | ||
const exec = param(childElem, childElem.state, childElem.context); | ||
if (childElem.state && exec) | ||
results.push(childElem); | ||
if (childElem.state && exec) results.push(childElem); | ||
} | ||
@@ -92,11 +79,8 @@ (_a = childElem == null ? void 0 : childElem.lookdownAll) == null ? void 0 : _a.call(childElem, param, results); | ||
const el = this; | ||
if (!((_a = el.node) == null ? void 0 : _a.style)) | ||
return; | ||
if (!((_a = el.node) == null ? void 0 : _a.style)) return; | ||
for (const param in params) { | ||
const value = params[param]; | ||
const childElem = el[param]; | ||
if (isObject(value) && childElem) | ||
setNodeStyles.call(childElem, value); | ||
else | ||
el.node.style[param] = value; | ||
if (isObject(value) && childElem) setNodeStyles.call(childElem, value); | ||
else el.node.style[param] = value; | ||
} | ||
@@ -108,6 +92,4 @@ return el; | ||
const beforeRemoveReturns = triggerEventOn("beforeRemove", element, opts); | ||
if (beforeRemoveReturns === false) | ||
return element; | ||
if (isFunction(element.node.remove)) | ||
element.node.remove(); | ||
if (beforeRemoveReturns === false) return element; | ||
if (isFunction(element.node.remove)) element.node.remove(); | ||
else if (!isProduction()) { | ||
@@ -118,4 +100,3 @@ console.warn("This item cant be removed"); | ||
delete element.parent[element.key]; | ||
if (element.parent.__ref) | ||
element.parent.__ref.__children = removeValueFromArray(element.parent.__ref.__children, element.key); | ||
if (element.parent.__ref) element.parent.__ref.__children = removeValueFromArray(element.parent.__ref.__children, element.key); | ||
triggerEventOn("remove", element, opts); | ||
@@ -129,4 +110,3 @@ } | ||
const element = this; | ||
if (!param || !element.props) | ||
return; | ||
if (!param || !element.props) return; | ||
element.update({ props: param }, options); | ||
@@ -158,13 +138,10 @@ return element; | ||
keyList.forEach((v) => { | ||
if (excl.includes(v)) | ||
return; | ||
if (excl.includes(v)) return; | ||
const val = element[v]; | ||
if (v === "state") { | ||
if (element.__ref && !element.__ref.__hasRootState) | ||
return; | ||
if (element.__ref && !element.__ref.__hasRootState) return; | ||
const parsedVal = isFunction(val && val.parse) ? val.parse() : val; | ||
obj[v] = isFunction(parsedVal) ? parsedVal : JSON.parse(JSON.stringify(parsedVal || {})); | ||
} else if (v === "scope") { | ||
if (element.__ref && !element.__ref.__hasRootScope) | ||
return; | ||
if (element.__ref && !element.__ref.__hasRootScope) return; | ||
obj[v] = JSON.parse(JSON.stringify(val || {})); | ||
@@ -174,4 +151,3 @@ } else if (v === "props") { | ||
obj[v] = props; | ||
} else if (isDefined(val) && Object.hasOwnProperty.call(element, v)) | ||
obj[v] = val; | ||
} else if (isDefined(val) && Object.hasOwnProperty.call(element, v)) obj[v] = val; | ||
}); | ||
@@ -184,4 +160,3 @@ return obj; | ||
for (const v in obj) { | ||
if (excl.includes(v)) | ||
return; | ||
if (excl.includes(v)) return; | ||
if (isObjectLike(obj[v])) { | ||
@@ -194,4 +169,3 @@ obj[v] = parseDeep.call(obj[v], excl); | ||
function verbose(...args) { | ||
if (ENV !== "test" && ENV !== "development") | ||
return; | ||
if (ENV !== "test" && ENV !== "development") return; | ||
const element = this; | ||
@@ -225,6 +199,4 @@ const { __ref: ref } = element; | ||
if (ENV === "test" || ENV === "development") { | ||
if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger) | ||
debugger; | ||
if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose) | ||
verbose.call(this); | ||
if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger) debugger; | ||
if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose) verbose.call(this); | ||
throw new Error(...params); | ||
@@ -245,4 +217,3 @@ } | ||
const { __children } = parent.__ref; | ||
if (!__children) | ||
return; | ||
if (!__children) return; | ||
const currentIndex = __children.indexOf(key); | ||
@@ -253,6 +224,4 @@ return parent[__children[currentIndex - 1]]; | ||
const element = this; | ||
if (!element.data) | ||
element.data = {}; | ||
if (!element.data.varCaches) | ||
element.data.varCaches = {}; | ||
if (!element.data) element.data = {}; | ||
if (!element.data.varCaches) element.data.varCaches = {}; | ||
const varCaches = element.data.varCaches; | ||
@@ -269,4 +238,3 @@ const changes = {}; | ||
changed: (cb) => { | ||
if (!changed) | ||
return; | ||
if (!changed) return; | ||
const returns = cb(changes, deepClone(varCaches)); | ||
@@ -279,4 +247,3 @@ for (const key in changes) { | ||
timeout: (cb, timeout) => { | ||
if (!changed) | ||
return; | ||
if (!changed) return; | ||
const t = setTimeout(() => { | ||
@@ -283,0 +250,0 @@ cb(changes); |
@@ -55,4 +55,3 @@ import { merge, overwrite } from "@domql/utils"; | ||
}; | ||
if (element.context.methods) | ||
(options.strict ? merge : overwrite)(proto, element.context.methods); | ||
if (element.context.methods) (options.strict ? merge : overwrite)(proto, element.context.methods); | ||
Object.setPrototypeOf(element, proto); | ||
@@ -59,0 +58,0 @@ }; |
@@ -20,15 +20,11 @@ import { isDefined, isFunction, isObjectLike } from "@domql/utils"; | ||
keyList.forEach((v) => { | ||
if (excl.includes(v)) | ||
return; | ||
if (excl.includes(v)) return; | ||
let val = element[v]; | ||
if (v === "state") { | ||
if (element.__ref && element.__ref.__hasRootState) | ||
return; | ||
if (isFunction(val && val.parse)) | ||
val = val.parse(); | ||
if (element.__ref && element.__ref.__hasRootState) return; | ||
if (isFunction(val && val.parse)) val = val.parse(); | ||
} else if (v === "props") { | ||
const { __element, update, ...props } = element[v]; | ||
obj[v] = props; | ||
} else if (isDefined(val)) | ||
obj[v] = val; | ||
} else if (isDefined(val)) obj[v] = val; | ||
}); | ||
@@ -41,4 +37,3 @@ return obj; | ||
for (const v in obj) { | ||
if (excl.includes(v)) | ||
return; | ||
if (excl.includes(v)) return; | ||
if (isObjectLike(obj[v])) { | ||
@@ -78,4 +73,3 @@ obj[v] = parseDeep.call(obj[v], excl); | ||
const { __children } = parent.__ref; | ||
if (!__children) | ||
return; | ||
if (!__children) return; | ||
const currentIndex = __children.indexOf(key); | ||
@@ -82,0 +76,0 @@ return parent[__children[currentIndex - 1]]; |
@@ -7,13 +7,9 @@ import { exec, isNot, isNull, isUndefined } from "@domql/utils"; | ||
const { __attr } = ref; | ||
if (isNot("object")) | ||
report("HTMLInvalidAttr", params); | ||
if (isNot("object")) report("HTMLInvalidAttr", params); | ||
if (params) { | ||
if (props.attr) | ||
deepMerge(params, props.attr); | ||
if (props.attr) deepMerge(params, props.attr); | ||
for (const attr2 in params) { | ||
const val = exec(params[attr2], element); | ||
if (val !== false && !isUndefined(val) && !isNull(val) && node.setAttribute) | ||
node.setAttribute(attr2, val); | ||
else if (node.removeAttribute) | ||
node.removeAttribute(attr2); | ||
if (val !== false && !isUndefined(val) && !isNull(val) && node.setAttribute) node.setAttribute(attr2, val); | ||
else if (node.removeAttribute) node.removeAttribute(attr2); | ||
__attr[attr2] = val; | ||
@@ -20,0 +16,0 @@ } |
import { exec, isObject, isString } from "@domql/utils"; | ||
const assignKeyAsClassname = (element) => { | ||
const { key } = element; | ||
if (element.class === true) | ||
element.class = key; | ||
if (element.class === true) element.class = key; | ||
else if (!element.class && typeof key === "string" && key.charAt(0) === "_" && key.charAt(1) !== "_") { | ||
@@ -14,6 +13,4 @@ element.class = key.slice(1); | ||
const param = obj[item]; | ||
if (typeof param === "boolean" && param) | ||
className += ` ${item}`; | ||
else if (typeof param === "string") | ||
className += ` ${param}`; | ||
if (typeof param === "boolean" && param) className += ` ${item}`; | ||
else if (typeof param === "string") className += ` ${param}`; | ||
else if (typeof param === "function") { | ||
@@ -26,14 +23,9 @@ className += ` ${exec(param, element)}`; | ||
const classList = (params, element) => { | ||
if (!params) | ||
return; | ||
if (!params) return; | ||
const { key } = element; | ||
if (params === true) | ||
params = element.class = { key }; | ||
if (isString(params)) | ||
params = element.class = { default: params }; | ||
if (isObject(params)) | ||
params = classify(params, element); | ||
if (params === true) params = element.class = { key }; | ||
if (isString(params)) params = element.class = { default: params }; | ||
if (isObject(params)) params = classify(params, element); | ||
const className = params.replace(/\s+/g, " ").trim(); | ||
if (element.ref) | ||
element.ref.class = className; | ||
if (element.ref) element.ref.class = className; | ||
return className; | ||
@@ -40,0 +32,0 @@ }; |
@@ -7,6 +7,4 @@ import { isFunction, setContentKey } from "@domql/utils"; | ||
const contentKey = ref.contentElementKey; | ||
if (!element[contentKey]) | ||
return; | ||
if (element[contentKey].update) | ||
element[contentKey].update(params, options); | ||
if (!element[contentKey]) return; | ||
if (element[contentKey].update) element[contentKey].update(params, options); | ||
}; | ||
@@ -17,12 +15,9 @@ const removeContent = function(el, opts = {}) { | ||
const contentElementKey = setContentKey(element, opts); | ||
if (opts.contentElementKey !== "content") | ||
opts.contentElementKey = "content"; | ||
if (opts.contentElementKey !== "content") opts.contentElementKey = "content"; | ||
if (element[contentElementKey]) { | ||
if (element[contentElementKey].node && element.node) { | ||
if (element[contentElementKey].tag === "fragment") | ||
element.node.innerHTML = ""; | ||
if (element[contentElementKey].tag === "fragment") element.node.innerHTML = ""; | ||
else { | ||
const contentNode = element[contentElementKey].node; | ||
if (contentNode.parentNode === element.node) | ||
element.node.removeChild(element[contentElementKey].node); | ||
if (contentNode.parentNode === element.node) element.node.removeChild(element[contentElementKey].node); | ||
} | ||
@@ -32,6 +27,4 @@ } | ||
if (__cached && __cached[contentElementKey]) { | ||
if (__cached[contentElementKey].tag === "fragment") | ||
__cached[contentElementKey].parent.node.innerHTML = ""; | ||
else if (__cached[contentElementKey] && isFunction(__cached[contentElementKey].remove)) | ||
__cached[contentElementKey].remove(); | ||
if (__cached[contentElementKey].tag === "fragment") __cached[contentElementKey].parent.node.innerHTML = ""; | ||
else if (__cached[contentElementKey] && isFunction(__cached[contentElementKey].remove)) __cached[contentElementKey].remove(); | ||
} | ||
@@ -38,0 +31,0 @@ delete element[contentElementKey]; |
@@ -5,7 +5,5 @@ import { exec, isObject, deepMerge } from "@domql/utils"; | ||
if (params) { | ||
if (element.props.data) | ||
deepMerge(params, element.props.data); | ||
if (element.props.data) deepMerge(params, element.props.data); | ||
if (params.showOnNode) { | ||
if (!isObject(params)) | ||
report("HTMLInvalidData", params); | ||
if (!isObject(params)) report("HTMLInvalidData", params); | ||
for (const dataset in params) { | ||
@@ -12,0 +10,0 @@ if (dataset !== "showOnNode") { |
@@ -7,6 +7,4 @@ import { exec } from "@domql/utils"; | ||
if (prop !== __ref.__html) { | ||
if (node.nodeName === "SVG") | ||
node.textContent = prop; | ||
else | ||
node.innerHTML = prop; | ||
if (node.nodeName === "SVG") node.textContent = prop; | ||
else node.innerHTML = prop; | ||
__ref.__html = prop; | ||
@@ -13,0 +11,0 @@ } |
import { isFunction, isObject } from "@domql/utils"; | ||
function scope(params, element, node) { | ||
if (!isObject(params)) | ||
return; | ||
if (!isObject(params)) return; | ||
for (const scopeItem in params) { | ||
@@ -6,0 +5,0 @@ const value = params[scopeItem]; |
@@ -7,6 +7,4 @@ import { IGNORE_STATE_PARAMS } from "@domql/state"; | ||
for (const param in state2) { | ||
if (IGNORE_STATE_PARAMS.includes(param)) | ||
continue; | ||
if (!Object.hasOwnProperty.call(state2, param)) | ||
continue; | ||
if (IGNORE_STATE_PARAMS.includes(param)) continue; | ||
if (!Object.hasOwnProperty.call(state2, param)) continue; | ||
} | ||
@@ -13,0 +11,0 @@ } |
@@ -5,6 +5,4 @@ import { isObject, map } from "@domql/utils"; | ||
if (params) { | ||
if (isObject(params)) | ||
map(node.style, params, element); | ||
else | ||
report("HTMLInvalidStyles", params); | ||
if (isObject(params)) map(node.style, params, element); | ||
else report("HTMLInvalidStyles", params); | ||
} | ||
@@ -11,0 +9,0 @@ } |
@@ -15,9 +15,6 @@ import { create } from "../create.js"; | ||
if (element.__text) { | ||
if (element.__text.text === prop) | ||
return; | ||
if (element.__text.text === prop) return; | ||
element.__text.text = prop; | ||
if (element.__text.node) | ||
element.__text.node.nodeValue = prop; | ||
} else | ||
create({ tag: "string", text: prop }, element, "__text"); | ||
if (element.__text.node) element.__text.node.nodeValue = prop; | ||
} else create({ tag: "string", text: prop }, element, "__text"); | ||
} | ||
@@ -24,0 +21,0 @@ } |
@@ -20,8 +20,6 @@ import { exec, isFunction, isObject, isUndefined, isVariant } from "@domql/utils"; | ||
isNewNode = true; | ||
if (!ref.__if) | ||
return element; | ||
if (!ref.__if) return element; | ||
if (tag === "shadow") { | ||
node = element.node = element.parent.node.attachShadow({ mode: "open" }); | ||
} else | ||
node = element.node = cacheNode(element); | ||
} else node = element.node = cacheNode(element); | ||
triggerEventOn("attachNode", element, options); | ||
@@ -31,4 +29,3 @@ } | ||
node.ref = element; | ||
if (isFunction(node.setAttribute)) | ||
node.setAttribute("key", element.key); | ||
if (isFunction(node.setAttribute)) node.setAttribute("key", element.key); | ||
} | ||
@@ -46,6 +43,4 @@ throughExecProps(element); | ||
const value = element[param]; | ||
if (!Object.hasOwnProperty.call(element, param)) | ||
continue; | ||
if (isUndefined(value) || isMethod(param, element) || isVariant(param) || isObject(REGISTRY[param])) | ||
continue; | ||
if (!Object.hasOwnProperty.call(element, param)) continue; | ||
if (isUndefined(value) || isMethod(param, element) || isVariant(param) || isObject(REGISTRY[param])) continue; | ||
const isElement = applyParam(param, element, options); | ||
@@ -65,4 +60,3 @@ if (isElement) { | ||
}); | ||
} else | ||
await createAsync(); | ||
} else await createAsync(); | ||
} | ||
@@ -69,0 +63,0 @@ } |
@@ -7,12 +7,8 @@ import { exec, isArray, isObject, deepClone, deepMerge } from "@domql/utils"; | ||
const propsStack = ref.__props = inheritParentProps(element, parent); | ||
if (isObject(props)) | ||
propsStack.push(props); | ||
else if (props === "inherit" && parent.props) | ||
propsStack.push(parent.props); | ||
else if (props) | ||
propsStack.push(props); | ||
if (isObject(props)) propsStack.push(props); | ||
else if (props === "inherit" && parent.props) propsStack.push(parent.props); | ||
else if (props) propsStack.push(props); | ||
if (isArray(ref.__extend)) { | ||
ref.__extend.forEach((extend) => { | ||
if (extend.props && extend.props !== props) | ||
propsStack.push(extend.props); | ||
if (extend.props && extend.props !== props) propsStack.push(extend.props); | ||
}); | ||
@@ -27,4 +23,3 @@ } | ||
props.forEach((v) => { | ||
if (IGNORE_PROPS_PARAMS.includes(v)) | ||
return; | ||
if (IGNORE_PROPS_PARAMS.includes(v)) return; | ||
let execProps; | ||
@@ -59,4 +54,3 @@ try { | ||
}; | ||
if (ref.__if) | ||
applyProps(); | ||
if (ref.__if) applyProps(); | ||
else { | ||
@@ -63,0 +57,0 @@ try { |
@@ -18,4 +18,3 @@ import { exec, is, isString } from "@domql/utils"; | ||
const inheritedStringExists = propsStack.filter((v) => v.inheritedString)[0]; | ||
if (inheritedStringExists) | ||
inheritedStringExists.inheritedString = matchParent; | ||
if (inheritedStringExists) inheritedStringExists.inheritedString = matchParent; | ||
else { | ||
@@ -28,4 +27,3 @@ propsStack = [].concat(objectizeStringProperty(matchParent), propsStack); | ||
} | ||
if (matchParentChildProps && !((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.ignoreChildProps)) | ||
propsStack.push(matchParentChildProps); | ||
if (matchParentChildProps && !((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.ignoreChildProps)) propsStack.push(matchParentChildProps); | ||
return propsStack; | ||
@@ -32,0 +30,0 @@ }; |
@@ -7,8 +7,5 @@ import { syncProps } from "./create.js"; | ||
const parentProps = inheritParentProps(element, parent); | ||
if (parentProps.length) | ||
propsStack = __ref.__props = [].concat(parentProps, propsStack); | ||
if (newProps) | ||
propsStack = __ref.__props = [].concat(newProps, propsStack); | ||
if (propsStack) | ||
syncProps(propsStack, element); | ||
if (parentProps.length) propsStack = __ref.__props = [].concat(parentProps, propsStack); | ||
if (newProps) propsStack = __ref.__props = [].concat(newProps, propsStack); | ||
if (propsStack) syncProps(propsStack, element); | ||
return element; | ||
@@ -15,0 +12,0 @@ }; |
@@ -8,4 +8,3 @@ import { deepContains, setContentKey } from "@domql/utils"; | ||
const resetElement = async (params, element, options) => { | ||
if (!options.preventRemove) | ||
removeContent(element, options); | ||
if (!options.preventRemove) removeContent(element, options); | ||
const { __ref: ref } = element; | ||
@@ -36,14 +35,10 @@ await create(params, element, ref.contentElementKey || "content", { | ||
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection; | ||
if (options.preventContentUpdate === true && !hasCollection) | ||
return; | ||
if (options.preventContentUpdate === true && !hasCollection) return; | ||
if (ref.__noCollectionDifference || __contentRef && __contentRef.__cached && deepContains(params, content)) { | ||
if (!options.preventBeforeUpdateListener && !options.preventListeners) { | ||
const beforeUpdateReturns = await triggerEventOnUpdate("beforeUpdate", params, element, options); | ||
if (beforeUpdateReturns === false) | ||
return element; | ||
if (beforeUpdateReturns === false) return element; | ||
} | ||
if (content == null ? void 0 : content.update) | ||
content.update(); | ||
if (!options.preventUpdateListener) | ||
await triggerEventOn("update", element, options); | ||
if (content == null ? void 0 : content.update) content.update(); | ||
if (!options.preventUpdateListener) await triggerEventOn("update", element, options); | ||
return; | ||
@@ -53,4 +48,3 @@ } | ||
let { childExtend, props } = params; | ||
if (!props) | ||
props = params.props = {}; | ||
if (!props) props = params.props = {}; | ||
if (!childExtend && element.childExtend) { | ||
@@ -71,4 +65,3 @@ params.childExtend = element.childExtend; | ||
}); | ||
} else | ||
await resetElement(params, element, options); | ||
} else await resetElement(params, element, options); | ||
} | ||
@@ -75,0 +68,0 @@ return element; |
@@ -45,13 +45,8 @@ import { | ||
let ref = element.__ref; | ||
if (!ref) | ||
ref = element.__ref = {}; | ||
if (!ref) ref = element.__ref = {}; | ||
const [snapshotOnCallee, calleeElement, snapshotHasUpdated] = captureSnapshot(element, options); | ||
if (snapshotHasUpdated) | ||
return; | ||
if (!options.preventListeners) | ||
await triggerEventOnUpdate("startUpdate", params, element, options); | ||
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element) | ||
return; | ||
if (!excludes) | ||
merge(options, UPDATE_DEFAULT_OPTIONS); | ||
if (snapshotHasUpdated) return; | ||
if (!options.preventListeners) await triggerEventOnUpdate("startUpdate", params, element, options); | ||
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element) return; | ||
if (!excludes) merge(options, UPDATE_DEFAULT_OPTIONS); | ||
if (isString(params) || isNumber(params)) { | ||
@@ -61,7 +56,5 @@ params = { text: params }; | ||
const inheritState = await inheritStateUpdates(element, options); | ||
if (inheritState === false) | ||
return; | ||
if (inheritState === false) return; | ||
const ifFails = checkIfOnUpdate(element, parent, options); | ||
if (ifFails) | ||
return; | ||
if (ifFails) return; | ||
if (ref.__if && !options.preventPropsUpdate) { | ||
@@ -71,9 +64,7 @@ const hasParentProps = parent.props && (parent.props[key] || parent.props.childProps); | ||
const props = params.props || hasParentProps || hasFunctionInProps.length; | ||
if (props) | ||
updateProps(props, element, parent); | ||
if (props) updateProps(props, element, parent); | ||
} | ||
if (!options.preventBeforeUpdateListener && !options.preventListeners) { | ||
const beforeUpdateReturns = await triggerEventOnUpdate("beforeUpdate", params, element, options); | ||
if (beforeUpdateReturns === false) | ||
return element; | ||
if (beforeUpdateReturns === false) return element; | ||
} | ||
@@ -87,4 +78,3 @@ overwriteDeep(element, params, { exclude: METHODS_EXL }); | ||
} | ||
if (!ref.__if) | ||
return false; | ||
if (!ref.__if) return false; | ||
if (!node) { | ||
@@ -104,20 +94,14 @@ return; | ||
if (preventUpdateAfter) { | ||
if (isNumber(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount) | ||
return; | ||
else if (options.preventUpdateAfterCount === void 0) | ||
options.preventUpdateAfterCount = 1; | ||
else | ||
options.preventUpdateAfterCount++; | ||
if (isNumber(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount) return; | ||
else if (options.preventUpdateAfterCount === void 0) options.preventUpdateAfterCount = 1; | ||
else options.preventUpdateAfterCount++; | ||
} | ||
for (const param in element) { | ||
const prop = element[param]; | ||
if (!Object.hasOwnProperty.call(element, param)) | ||
continue; | ||
if (!Object.hasOwnProperty.call(element, param)) continue; | ||
const isInPreventUpdate = isArray(preventUpdate) && preventUpdate.includes(param); | ||
const isInPreventDefineUpdate = isArray(preventDefineUpdate) && preventDefineUpdate.includes(param); | ||
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection; | ||
if (isUndefined(prop) || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || isMethod(param, element) || isObject(REGISTRY[param]) || isVariant(param)) | ||
continue; | ||
if (preventStateUpdate === "once") | ||
options.preventStateUpdate = false; | ||
if (isUndefined(prop) || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || isMethod(param, element) || isObject(REGISTRY[param]) || isVariant(param)) continue; | ||
if (preventStateUpdate === "once") options.preventStateUpdate = false; | ||
const isElement = applyParam(param, element, options); | ||
@@ -127,4 +111,3 @@ if (isElement) { | ||
const canUpdate = isObject(prop) && !hasDefine && !hasContextDefine && !preventRecursive; | ||
if (!canUpdate) | ||
continue; | ||
if (!canUpdate) continue; | ||
const lazyLoad = element.props.lazyLoad || options.lazyLoad; | ||
@@ -147,4 +130,3 @@ if (options.onEachUpdate) { | ||
} | ||
if (!preventUpdateListener) | ||
triggerEventOn("update", element, options); | ||
if (!preventUpdateListener) triggerEventOn("update", element, options); | ||
}; | ||
@@ -168,4 +150,3 @@ const captureSnapshot = (element, options) => { | ||
var _a, _b, _c; | ||
if (!isFunction(element.if) && !isFunction((_a = element.props) == null ? void 0 : _a.if) || !parent) | ||
return; | ||
if (!isFunction(element.if) && !isFunction((_a = element.props) == null ? void 0 : _a.if) || !parent) return; | ||
const ref = element.__ref; | ||
@@ -195,4 +176,3 @@ const ifPassed = (element.if || ((_b = element.props) == null ? void 0 : _b.if))(element, element.state, element.context, options); | ||
element.removeContent(); | ||
} else if ((_c = element[contentKey]) == null ? void 0 : _c.parseDeep) | ||
element[contentKey] = element[contentKey].parseDeep(); | ||
} else if ((_c = element[contentKey]) == null ? void 0 : _c.parseDeep) element[contentKey] = element[contentKey].parseDeep(); | ||
const previousElement = element.previousElement(); | ||
@@ -226,4 +206,3 @@ const previousNode = previousElement == null ? void 0 : previousElement.node; | ||
const { preventUpdateTriggerStateUpdate, isHoisted, execStateFunction } = options; | ||
if (preventUpdateTriggerStateUpdate) | ||
return; | ||
if (preventUpdateTriggerStateUpdate) return; | ||
if (!stateKey && !ref.__hasRootState) { | ||
@@ -240,8 +219,6 @@ element.state = parent && parent.state || {}; | ||
const keyInParentState = findInheritedState(element, element.parent); | ||
if (!keyInParentState || options.preventInheritedStateUpdate) | ||
return; | ||
if (!keyInParentState || options.preventInheritedStateUpdate) return; | ||
if (!options.preventBeforeStateUpdateListener && !options.preventListeners) { | ||
const initStateReturns = await triggerEventOnUpdate("beforeStateUpdate", keyInParentState, element, options); | ||
if (initStateReturns === false) | ||
return element; | ||
if (initStateReturns === false) return element; | ||
} | ||
@@ -258,4 +235,3 @@ const newState = createStateUpdate(element, parent, options); | ||
for (const child in __stateChildren) { | ||
if (newState[child]) | ||
newState.__children[child] = __stateChildren[child]; | ||
if (newState[child]) newState.__children[child] = __stateChildren[child]; | ||
Object.getPrototypeOf(__stateChildren[child]).parent = newState; | ||
@@ -262,0 +238,0 @@ } |
@@ -12,4 +12,3 @@ import { isFunction } from "@domql/utils"; | ||
const hasContextDefine = context && context.define && context.define[param]; | ||
if (!ref.__if) | ||
return; | ||
if (!ref.__if) return; | ||
const hasOnlyUpdate = onlyUpdate ? onlyUpdate === param || element.lookup(onlyUpdate) : true; | ||
@@ -16,0 +15,0 @@ if (isGlobalTransformer && !hasContextDefine && hasOnlyUpdate) { |
@@ -32,4 +32,3 @@ import { | ||
let variantElement = element[variant]; | ||
if (!variantElement) | ||
return; | ||
if (!variantElement) return; | ||
const props = isObject(variantProps) ? variantProps : {}; | ||
@@ -49,4 +48,3 @@ if (isString(variantElement)) { | ||
const { props } = element; | ||
if (!hasVariantProp(element)) | ||
return element; | ||
if (!hasVariantProp(element)) return element; | ||
const { variant } = props; | ||
@@ -58,4 +56,3 @@ overwriteVariant(element, `.${variant}`); | ||
const variantElementProps = props[slicedVariantElementKey]; | ||
if (variantElementProps) | ||
overwriteVariant(element, variant2, variantElementProps); | ||
if (variantElementProps) overwriteVariant(element, variant2, variantElementProps); | ||
}); | ||
@@ -62,0 +59,0 @@ return element; |
@@ -35,11 +35,7 @@ import { isArray, isFunction, isObject, isString, deepClone } from "@domql/utils"; | ||
const flattenExtend = (extend, stack, context) => { | ||
if (!extend) | ||
return stack; | ||
if (isArray(extend)) | ||
return extractArrayExtend(extend, stack, context); | ||
if (isString(extend)) | ||
extend = fallbackStringExtend(extend, context); | ||
if (!extend) return stack; | ||
if (isArray(extend)) return extractArrayExtend(extend, stack, context); | ||
if (isString(extend)) extend = fallbackStringExtend(extend, context); | ||
stack.push(extend); | ||
if (extend.extend) | ||
deepExtend(extend, stack, context); | ||
if (extend.extend) deepExtend(extend, stack, context); | ||
return stack; | ||
@@ -49,4 +45,3 @@ }; | ||
for (const e in extend) { | ||
if (["parent", "node", "__element"].indexOf(e) > -1) | ||
continue; | ||
if (["parent", "node", "__element"].indexOf(e) > -1) continue; | ||
const elementProp = element[e]; | ||
@@ -80,6 +75,4 @@ const extendProp = extend[e]; | ||
const pageExists = PAGES && extend.startsWith("/") && PAGES[extend]; | ||
if (componentExists) | ||
return componentExists; | ||
else if (pageExists) | ||
return pageExists; | ||
if (componentExists) return componentExists; | ||
else if (pageExists) return pageExists; | ||
else { | ||
@@ -98,6 +91,4 @@ if (options.verbose && (ENV === "test" || ENV === "development")) { | ||
const getExtendStack = (extend, context) => { | ||
if (!extend) | ||
return []; | ||
if (extend.__hash) | ||
return getHashedExtend(extend) || []; | ||
if (!extend) return []; | ||
if (extend.__hash) return getHashedExtend(extend) || []; | ||
const stack = flattenExtend(extend, [], context); | ||
@@ -104,0 +95,0 @@ return getExtendStackRegistry(extend, stack); |
@@ -66,4 +66,3 @@ import { isArray, isObject, isObjectLike, joinArrays, deepClone } from "@domql/utils"; | ||
for (const e in extend) { | ||
if (exclude.includes(e)) | ||
continue; | ||
if (exclude.includes(e)) continue; | ||
const elementProp = element[e]; | ||
@@ -82,4 +81,3 @@ const extendProp = extend[e]; | ||
for (const e in obj) { | ||
if (exclude.includes(e)) | ||
continue; | ||
if (exclude.includes(e)) continue; | ||
o[e] = obj[e]; | ||
@@ -94,4 +92,3 @@ } | ||
for (const e in params) { | ||
if (e === "props" || e === "state" || e === "__ref") | ||
continue; | ||
if (e === "props" || e === "state" || e === "__ref") continue; | ||
const elementProp = element[e]; | ||
@@ -103,4 +100,3 @@ const paramsProp = params[e]; | ||
} | ||
if (options.cleanExec) | ||
delete __exec[e]; | ||
if (options.cleanExec) delete __exec[e]; | ||
} | ||
@@ -111,4 +107,3 @@ return changes; | ||
for (const e in params) { | ||
if (exclude.includes(e)) | ||
continue; | ||
if (exclude.includes(e)) continue; | ||
obj[e] = params[e]; | ||
@@ -120,4 +115,3 @@ } | ||
for (const e in params) { | ||
if (exclude.includes(e)) | ||
continue; | ||
if (exclude.includes(e)) continue; | ||
const objProp = obj[e]; | ||
@@ -134,4 +128,3 @@ const paramsProp = params[e]; | ||
const mergeIfExisted = (a, b) => { | ||
if (isObjectLike(a) && isObjectLike(b)) | ||
return deepMerge(a, b); | ||
if (isObjectLike(a) && isObjectLike(b)) return deepMerge(a, b); | ||
return a || b; | ||
@@ -149,4 +142,3 @@ }; | ||
const extendOfExtend = objectized[prop]; | ||
if (extendOfExtend) | ||
flattenRecursive(extendOfExtend, prop, stack); | ||
if (extendOfExtend) flattenRecursive(extendOfExtend, prop, stack); | ||
delete objectized[prop]; | ||
@@ -153,0 +145,0 @@ return stack; |
@@ -16,20 +16,11 @@ import { exec, isFunction, isObject, isUndefined } from "@domql/utils"; | ||
const { __ref: ref2 } = element; | ||
if (!ref2.__cached) | ||
ref2.__cached = {}; | ||
if (!ref2.__defineCache) | ||
ref2.__defineCache = {}; | ||
if (!ref2.__exec) | ||
ref2.__exec = {}; | ||
if (!ref2.__execProps) | ||
ref2.__execProps = {}; | ||
if (!ref2.__class) | ||
ref2.__class = {}; | ||
if (!ref2.__classNames) | ||
ref2.__classNames = {}; | ||
if (!ref2.__attr) | ||
ref2.__attr = {}; | ||
if (!ref2.__changes) | ||
ref2.__changes = []; | ||
if (!ref2.__children) | ||
ref2.__children = []; | ||
if (!ref2.__cached) ref2.__cached = {}; | ||
if (!ref2.__defineCache) ref2.__defineCache = {}; | ||
if (!ref2.__exec) ref2.__exec = {}; | ||
if (!ref2.__execProps) ref2.__execProps = {}; | ||
if (!ref2.__class) ref2.__class = {}; | ||
if (!ref2.__classNames) ref2.__classNames = {}; | ||
if (!ref2.__attr) ref2.__attr = {}; | ||
if (!ref2.__changes) ref2.__changes = []; | ||
if (!ref2.__children) ref2.__children = []; | ||
} | ||
@@ -43,6 +34,4 @@ addMethods(element, parent, options); | ||
delete ref.__if; | ||
} else | ||
ref.__if = true; | ||
} else | ||
ref.__if = true; | ||
} else ref.__if = true; | ||
} else ref.__if = true; | ||
if (element.node && ref.__if) { | ||
@@ -58,4 +47,3 @@ parent[key || element.key] = element; | ||
const prop = element[param]; | ||
if (isUndefined(prop) || isMethod(param, element) || isObject(REGISTRY[param]) || isVariant(param)) | ||
continue; | ||
if (isUndefined(prop) || isMethod(param, element) || isObject(REGISTRY[param]) || isVariant(param)) continue; | ||
const hasDefine = element.define && element.define[param]; | ||
@@ -78,4 +66,3 @@ const contextHasDefine = element.context && element.context.define && element.context.define[param]; | ||
} | ||
if (!options.keepRef) | ||
delete element.__ref; | ||
if (!options.keepRef) delete element.__ref; | ||
return element; | ||
@@ -82,0 +69,0 @@ }; |
@@ -12,7 +12,5 @@ import { isFunction, lowercaseFirstLetter } from "@domql/utils"; | ||
const originalEventRetunrs = origEvent(...args); | ||
if (originalEventRetunrs !== false) | ||
funcFromProps(...args); | ||
if (originalEventRetunrs !== false) funcFromProps(...args); | ||
}; | ||
} else | ||
on[eventName] = funcFromProps; | ||
} else on[eventName] = funcFromProps; | ||
}); | ||
@@ -19,0 +17,0 @@ }; |
{ | ||
"name": "@domql/element", | ||
"version": "2.5.198", | ||
"version": "2.5.200", | ||
"license": "MIT", | ||
@@ -30,8 +30,8 @@ "type": "module", | ||
"dependencies": { | ||
"@domql/event": "^2.5.190", | ||
"@domql/render": "^2.5.190", | ||
"@domql/state": "^2.5.198", | ||
"@domql/utils": "^2.5.187" | ||
"@domql/event": "^2.5.200", | ||
"@domql/render": "^2.5.200", | ||
"@domql/state": "^2.5.200", | ||
"@domql/utils": "^2.5.200" | ||
}, | ||
"gitHead": "045032f5c80a92a1a05b0dfff68c93c9b32e6bd9", | ||
"gitHead": "0afb63ec375f0526f47ff300885de393138b01e8", | ||
"devDependencies": { | ||
@@ -38,0 +38,0 @@ "@babel/core": "^7.12.0" |
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
9
350%270020
-0.85%480
-58.44%7447
-5.36%1
Infinity%