@domql/element 2.3.154 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/cache/index.js +3 -0
  3. package/create.js +21 -35
  4. package/dist/cjs/applyParam.js +41 -0
  5. package/dist/cjs/create.js +262 -0
  6. package/dist/cjs/define.js +34 -0
  7. package/dist/cjs/extend.js +87 -0
  8. package/dist/cjs/index.js +44 -0
  9. package/dist/cjs/iterate.js +108 -0
  10. package/dist/cjs/node.js +85 -0
  11. package/dist/cjs/package.json +4 -0
  12. package/dist/cjs/set.js +58 -0
  13. package/dist/cjs/tree.js +31 -0
  14. package/dist/cjs/update.js +223 -0
  15. package/index.js +2 -12
  16. package/iterate.js +1 -1
  17. package/methods/index.js +165 -0
  18. package/methods/set.js +41 -0
  19. package/{methods.js → methods/v2.js} +1 -7
  20. package/mixins/attr.js +23 -0
  21. package/mixins/classList.js +48 -0
  22. package/{remove.js → mixins/content.js} +19 -2
  23. package/mixins/data.js +21 -0
  24. package/mixins/html.js +20 -0
  25. package/mixins/index.js +23 -0
  26. package/mixins/registry.js +66 -0
  27. package/mixins/state.js +20 -0
  28. package/mixins/style.js +14 -0
  29. package/mixins/text.js +41 -0
  30. package/node.js +2 -2
  31. package/package.json +14 -6
  32. package/props/create.js +60 -0
  33. package/props/ignore.js +3 -0
  34. package/props/index.js +6 -0
  35. package/props/inherit.js +34 -0
  36. package/props/update.js +17 -0
  37. package/set.js +4 -6
  38. package/test/create.test.js +61 -0
  39. package/test/set.test.js +13 -0
  40. package/test/update.test.js +13 -0
  41. package/tree.js +11 -0
  42. package/update.js +5 -7
  43. package/utils/component.js +112 -0
  44. package/utils/extendUtils.js +118 -0
  45. package/utils/index.js +5 -0
  46. package/utils/object.js +141 -0
  47. package/parse.js +0 -17
  48. /package/{options.js → cache/options.js} +0 -0
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var iterate_exports = {};
20
+ __export(iterate_exports, {
21
+ throughInitialDefine: () => throughInitialDefine,
22
+ throughInitialExec: () => throughInitialExec,
23
+ throughUpdatedDefine: () => throughUpdatedDefine,
24
+ throughUpdatedExec: () => throughUpdatedExec
25
+ });
26
+ module.exports = __toCommonJS(iterate_exports);
27
+ var import_utils = require("@domql/utils");
28
+ var import_utils2 = require("./utils");
29
+ var import_methods = require("./methods");
30
+ const throughInitialExec = (element, exclude = {}) => {
31
+ const { __ref: ref } = element;
32
+ for (const param in element) {
33
+ if (exclude[param])
34
+ continue;
35
+ const prop = element[param];
36
+ if ((0, import_utils.isFunction)(prop) && !(0, import_methods.isMethod)(param) && !(0, import_utils2.isVariant)(param)) {
37
+ ref.__exec[param] = prop;
38
+ element[param] = prop(element, element.state);
39
+ }
40
+ }
41
+ };
42
+ const throughUpdatedExec = (element, options = { excludes: import_utils2.METHODS_EXL }) => {
43
+ const { __ref: ref } = element;
44
+ const changes = {};
45
+ for (const param in ref.__exec) {
46
+ const prop = element[param];
47
+ const isDefinedParam = ref.__defineCache[param];
48
+ if (isDefinedParam)
49
+ continue;
50
+ const newExec = ref.__exec[param](element, element.state, element.context);
51
+ const execReturnsString = (0, import_utils.isString)(newExec) || (0, import_utils.isNumber)(newExec);
52
+ if (prop && prop.node && execReturnsString) {
53
+ (0, import_utils2.overwrite)(prop, { text: newExec }, options);
54
+ } else if (newExec !== prop) {
55
+ if ((0, import_utils2.checkIfKeyIsComponent)(param)) {
56
+ const { extend, ...newElem } = (0, import_utils2.extendizeByKey)(newExec, element, param);
57
+ (0, import_utils2.overwrite)(prop, newElem, options);
58
+ } else {
59
+ ref.__cached[param] = changes[param] = prop;
60
+ element[param] = newExec;
61
+ }
62
+ }
63
+ }
64
+ return changes;
65
+ };
66
+ const throughInitialDefine = (element) => {
67
+ const { define, context, __ref: ref } = element;
68
+ let defineObj = {};
69
+ const hasGlobalDefine = context && (0, import_utils.isObject)(context.define);
70
+ if ((0, import_utils.isObject)(define))
71
+ defineObj = { ...define };
72
+ if (hasGlobalDefine)
73
+ defineObj = { ...defineObj, ...context.define };
74
+ for (const param in defineObj) {
75
+ let elementProp = element[param];
76
+ if ((0, import_utils.isFunction)(elementProp) && !(0, import_methods.isMethod)(param) && !(0, import_utils2.isVariant)(param)) {
77
+ ref.__exec[param] = elementProp;
78
+ const execParam2 = elementProp = (0, import_utils.exec)(elementProp, element);
79
+ if (execParam2) {
80
+ elementProp = element[param] = execParam2.parse ? execParam2.parse() : execParam2;
81
+ ref.__defineCache[param] = elementProp;
82
+ }
83
+ }
84
+ const execParam = defineObj[param](elementProp, element, element.state, element.context);
85
+ if (execParam)
86
+ element[param] = execParam;
87
+ }
88
+ return element;
89
+ };
90
+ const throughUpdatedDefine = (element) => {
91
+ const { context, define, __ref: ref } = element;
92
+ const changes = {};
93
+ let obj = {};
94
+ if ((0, import_utils.isObject)(define))
95
+ obj = { ...define };
96
+ if ((0, import_utils.isObject)(context && context.define))
97
+ obj = { ...obj, ...context.define };
98
+ for (const param in obj) {
99
+ const execParam = ref.__exec[param];
100
+ if (execParam)
101
+ ref.__defineCache[param] = execParam(element, element.state, element.context);
102
+ const cached = (0, import_utils.exec)(ref.__defineCache[param], element);
103
+ const newExecParam = obj[param](cached, element, element.state, element.context);
104
+ if (newExecParam)
105
+ element[param] = newExecParam;
106
+ }
107
+ return changes;
108
+ };
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var node_exports = {};
30
+ __export(node_exports, {
31
+ createNode: () => createNode,
32
+ default: () => node_default
33
+ });
34
+ module.exports = __toCommonJS(node_exports);
35
+ var import_utils = require("@domql/utils");
36
+ var import_event = require("@domql/event");
37
+ var import_methods = require("./methods");
38
+ var import_node = require("@domql/node");
39
+ var import_create = __toESM(require("./create"), 1);
40
+ var import_iterate = require("./iterate");
41
+ var import_mixins = require("./mixins");
42
+ var import_applyParam = require("./applyParam");
43
+ var import_utils2 = require("./utils");
44
+ const ENV = "development";
45
+ const createNode = (element, options) => {
46
+ let { node, tag, __ref: ref } = element;
47
+ let isNewNode;
48
+ if (!node) {
49
+ isNewNode = true;
50
+ if (!ref.__if)
51
+ return element;
52
+ if (tag === "shadow") {
53
+ node = element.node = element.parent.node.attachShadow({ mode: "open" });
54
+ } else
55
+ node = element.node = (0, import_node.cacheNode)(element);
56
+ (0, import_event.triggerEventOn)("attachNode", element, options);
57
+ }
58
+ if (ENV === "test" || ENV === "development" || options.alowRefReference) {
59
+ node.ref = element;
60
+ if ((0, import_utils.isFunction)(node.setAttribute))
61
+ node.setAttribute("key", element.key);
62
+ }
63
+ if (!ref.__if)
64
+ return element;
65
+ if (element.tag !== "string" || element.tag !== "fragment") {
66
+ (0, import_iterate.throughInitialDefine)(element);
67
+ (0, import_iterate.throughInitialExec)(element);
68
+ if (isNewNode && (0, import_utils.isObject)(element.on))
69
+ (0, import_event.applyEventsOnNode)(element);
70
+ for (const param in element) {
71
+ const prop = element[param];
72
+ if ((0, import_utils.isUndefined)(prop) || (0, import_methods.isMethod)(param) || (0, import_utils2.isVariant)(param) || (0, import_utils.isObject)(import_mixins.registry[param]))
73
+ continue;
74
+ const isElement = (0, import_applyParam.applyParam)(param, element, options);
75
+ if (isElement) {
76
+ const { hasDefine, hasContextDefine } = isElement;
77
+ if (element[param] && !hasDefine && !hasContextDefine) {
78
+ (0, import_create.default)((0, import_utils.exec)(prop, element), element, param, options);
79
+ }
80
+ }
81
+ }
82
+ }
83
+ return element;
84
+ };
85
+ var node_default = createNode;
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "commonjs",
3
+ "main": "index.js"
4
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var set_exports = {};
30
+ __export(set_exports, {
31
+ default: () => set_default
32
+ });
33
+ module.exports = __toCommonJS(set_exports);
34
+ var import_utils = require("@domql/utils");
35
+ var import_create = __toESM(require("./create"), 1);
36
+ var import_options = __toESM(require("./cache/options"), 1);
37
+ var import_mixins = require("./mixins");
38
+ var import_content = require("./mixins/content");
39
+ const set = function(params, options = {}, el) {
40
+ const element = el || this;
41
+ const __contentRef = element.content && element.content.__ref;
42
+ if (__contentRef && __contentRef.__cached && (0, import_utils.isEqualDeep)(params, element.content))
43
+ return element;
44
+ (0, import_content.removeContent)(element);
45
+ if (params) {
46
+ const { childExtend } = params;
47
+ if (!childExtend && element.childExtend)
48
+ params.childExtend = element.childExtend;
49
+ (0, import_create.default)(params, element, "content", {
50
+ ignoreChildExtend: true,
51
+ ...import_mixins.registry.defaultOptions,
52
+ ...import_options.default.create,
53
+ ...options
54
+ });
55
+ }
56
+ return element;
57
+ };
58
+ var set_default = set;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var tree_exports = {};
20
+ __export(tree_exports, {
21
+ ROOT: () => ROOT,
22
+ TREE: () => TREE
23
+ });
24
+ module.exports = __toCommonJS(tree_exports);
25
+ var import_utils = require("@domql/utils");
26
+ var import_report = require("@domql/report");
27
+ const ROOT = {
28
+ key: ":root",
29
+ node: import_utils.document ? import_utils.document.body : (0, import_report.report)("DocumentNotDefined", import_utils.document)
30
+ };
31
+ const TREE = ROOT;
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var update_exports = {};
30
+ __export(update_exports, {
31
+ default: () => update_default
32
+ });
33
+ module.exports = __toCommonJS(update_exports);
34
+ var import_utils = require("@domql/utils");
35
+ var import_event = require("@domql/event");
36
+ var import_methods = require("./methods");
37
+ var import_props = require("./props");
38
+ var import_state = require("@domql/state");
39
+ var import_utils2 = require("./utils");
40
+ var import_create = __toESM(require("./create"), 1);
41
+ var import_iterate = require("./iterate");
42
+ var import_mixins = require("./mixins");
43
+ var import_applyParam = require("./applyParam");
44
+ var import_options = __toESM(require("./cache/options"), 1);
45
+ const snapshot = {
46
+ snapshotId: import_utils.createSnapshotId
47
+ };
48
+ const UPDATE_DEFAULT_OPTIONS = {
49
+ stackChanges: false,
50
+ cleanExec: true,
51
+ preventRecursive: false,
52
+ currentSnapshot: false,
53
+ calleeElement: false,
54
+ excludes: import_utils2.METHODS_EXL
55
+ };
56
+ const update = function(params = {}, options = UPDATE_DEFAULT_OPTIONS) {
57
+ const element = this;
58
+ const { parent, node, key } = element;
59
+ const { excludes, preventInheritAtCurrentState } = options;
60
+ if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element)
61
+ return;
62
+ if (!excludes)
63
+ (0, import_utils.merge)(options, UPDATE_DEFAULT_OPTIONS);
64
+ let ref = element.__ref;
65
+ if (!ref)
66
+ ref = element.__ref = {};
67
+ const [snapshotOnCallee, calleeElement, snapshotHasUpdated] = captureSnapshot(element, options);
68
+ if (snapshotHasUpdated)
69
+ return;
70
+ if ((0, import_utils.isString)(params) || (0, import_utils.isNumber)(params)) {
71
+ params = { text: params };
72
+ }
73
+ const ifFails = checkIfOnUpdate(element, parent, options);
74
+ if (ifFails)
75
+ return;
76
+ const inheritState = inheritStateUpdates(element, options);
77
+ if (inheritState === false)
78
+ return;
79
+ if (ref.__if && !options.preventPropsUpdate) {
80
+ const hasParentProps = parent.props && (parent.props[key] || parent.props.childProps);
81
+ const hasFunctionInProps = ref.__props.filter((v) => (0, import_utils.isFunction)(v));
82
+ const props = params.props || hasParentProps || hasFunctionInProps.length;
83
+ if (props)
84
+ (0, import_props.updateProps)(props, element, parent);
85
+ }
86
+ if (!options.isForced) {
87
+ (0, import_event.triggerEventOn)("beforeClassAssign", element, options);
88
+ }
89
+ if (!options.preventInitUpdateListener) {
90
+ const initUpdateReturns = (0, import_event.triggerEventOnUpdate)("initUpdate", params, element, options);
91
+ if (initUpdateReturns === false)
92
+ return element;
93
+ }
94
+ const overwriteChanges = (0, import_utils.overwriteDeep)(element, params, import_utils2.METHODS_EXL);
95
+ const execChanges = (0, import_iterate.throughUpdatedExec)(element, { ignore: UPDATE_DEFAULT_OPTIONS });
96
+ const definedChanges = (0, import_iterate.throughUpdatedDefine)(element);
97
+ if (options.stackChanges && element.__stackChanges) {
98
+ const stackChanges = (0, import_utils.merge)(definedChanges, (0, import_utils.merge)(execChanges, overwriteChanges));
99
+ element.__stackChanges.push(stackChanges);
100
+ }
101
+ if (!ref.__if)
102
+ return false;
103
+ if (!node) {
104
+ return;
105
+ }
106
+ for (const param in element) {
107
+ const prop = element[param];
108
+ const hasOnlyUpdateFalsy = options.onlyUpdate && (options.onlyUpdate !== param || !element.lookup(options.onlyUpdate));
109
+ const isInPreventUpdate = (0, import_utils.isArray)(options.preventUpdate) && options.preventUpdate.includes(param);
110
+ const isInPreventDefineUpdate = (0, import_utils.isArray)(options.preventDefineUpdate) && options.preventDefineUpdate.includes(param);
111
+ if ((0, import_utils.isUndefined)(prop) || hasOnlyUpdateFalsy || isInPreventUpdate || isInPreventDefineUpdate || options.preventDefineUpdate === true || options.preventDefineUpdate === param || options.preventContentUpdate && param === "content" || (options.preventStateUpdate && param) === "state" || (0, import_methods.isMethod)(param) || (0, import_utils.isObject)(import_mixins.registry[param]) || (0, import_utils2.isVariant)(param))
112
+ continue;
113
+ if (options.preventStateUpdate === "once")
114
+ options.preventStateUpdate = false;
115
+ const isElement = (0, import_applyParam.applyParam)(param, element, options);
116
+ if (isElement) {
117
+ const { hasDefine, hasContextDefine } = isElement;
118
+ const canUpdate = (0, import_utils.isObject)(prop) && !hasDefine && !hasContextDefine && !options.preventRecursive;
119
+ if (!canUpdate)
120
+ continue;
121
+ const childUpdateCall = () => update.call(prop, params[prop], {
122
+ ...options,
123
+ currentSnapshot: snapshotOnCallee,
124
+ calleeElement
125
+ });
126
+ if (element.props && element.props.lazyLoad || options.lazyLoad) {
127
+ import_utils.window.requestAnimationFrame(() => childUpdateCall());
128
+ } else
129
+ childUpdateCall();
130
+ }
131
+ }
132
+ if (!options.preventUpdateListener)
133
+ (0, import_event.triggerEventOn)("update", element, options);
134
+ };
135
+ const captureSnapshot = (element, options) => {
136
+ const ref = element.__ref;
137
+ const { currentSnapshot, calleeElement } = options;
138
+ const isCallee = calleeElement === element;
139
+ if (!calleeElement || isCallee) {
140
+ const createdStanpshot = snapshot.snapshotId();
141
+ ref.__currentSnapshot = createdStanpshot;
142
+ return [createdStanpshot, element];
143
+ }
144
+ const snapshotOnCallee = ref.__currentSnapshot;
145
+ if (currentSnapshot < snapshotOnCallee) {
146
+ return [snapshotOnCallee, calleeElement, true];
147
+ }
148
+ return [snapshotOnCallee, calleeElement];
149
+ };
150
+ const checkIfOnUpdate = (element, parent, options) => {
151
+ if (!(0, import_utils.isFunction)(element.if) || !element.state || !parent)
152
+ return;
153
+ const ref = element.__ref;
154
+ const ifPassed = element.if(element, element.state, element.context, options);
155
+ const itWasFalse = ref.__if !== true;
156
+ if (ifPassed) {
157
+ ref.__if = true;
158
+ if (itWasFalse) {
159
+ delete element.__hash;
160
+ delete element.extend;
161
+ if (!ref.__hasRootState) {
162
+ delete element.state;
163
+ }
164
+ if (ref.__state) {
165
+ element.state = ref.__state;
166
+ }
167
+ const created = (0, import_create.default)(element, parent, element.key, import_options.default.create);
168
+ if (options.preventUpdate !== true && element.on && (0, import_utils.isFunction)(element.on.update)) {
169
+ (0, import_event.applyEvent)(element.on.update, created, created.state);
170
+ }
171
+ return created;
172
+ }
173
+ } else if (element.node && !ifPassed) {
174
+ element.node.remove();
175
+ delete ref.__if;
176
+ }
177
+ };
178
+ const inheritStateUpdates = (element, options) => {
179
+ const { __ref: ref } = element;
180
+ const stateKey = ref.__state;
181
+ const { parent, state } = element;
182
+ if (options.preventpdateTriggerStateUpdate)
183
+ return;
184
+ if (!stateKey && !ref.__hasRootState) {
185
+ element.state = parent && parent.state || {};
186
+ return;
187
+ }
188
+ const { isHoisted, execStateFunction, stateFunctionOverwrite } = options;
189
+ const shouldForceStateUpdate = (0, import_utils.isFunction)(stateKey) && (!isHoisted && execStateFunction && stateFunctionOverwrite);
190
+ if (shouldForceStateUpdate) {
191
+ const execState = (0, import_utils.exec)(stateKey, element);
192
+ state.set(execState, {
193
+ ...options,
194
+ preventUpdate: true
195
+ });
196
+ return;
197
+ }
198
+ const parentState = parent && parent.state || {};
199
+ const keyInParentState = parentState[stateKey];
200
+ if (!keyInParentState || options.preventInheritedStateUpdate)
201
+ return;
202
+ if (!options.preventInitStateUpdateListener) {
203
+ const initStateReturns = (0, import_event.triggerEventOnUpdate)("initStateUpdated", keyInParentState, element, options);
204
+ if (initStateReturns === false)
205
+ return element;
206
+ }
207
+ const newState = createStateUpdate(element, parent, options);
208
+ if (!options.preventStateUpdateListener) {
209
+ (0, import_event.triggerEventOnUpdate)("stateUpdated", newState.parse(), element, options);
210
+ }
211
+ };
212
+ const createStateUpdate = (element, parent, options) => {
213
+ const __stateChildren = element.state.__children;
214
+ const newState = (0, import_state.createState)(element, parent);
215
+ element.state = newState;
216
+ for (const child in __stateChildren) {
217
+ if (newState[child])
218
+ newState.__children[child] = __stateChildren[child];
219
+ __stateChildren[child].parent = newState;
220
+ }
221
+ return newState;
222
+ };
223
+ var update_default = update;
package/index.js CHANGED
@@ -1,27 +1,17 @@
1
1
  'use strict'
2
2
 
3
- import { TREE } from '@domql/tree'
3
+ import { TREE } from './tree'
4
4
  import create from './create'
5
5
  import createNode from './node'
6
6
  import define from './define'
7
7
  import update from './update'
8
- import parse from './parse'
9
8
  import set from './set'
10
9
 
11
- import { log, keys } from './methods'
12
- import { get, remove, lookup } from '@domql/methods'
13
-
14
10
  export {
15
11
  TREE,
16
12
  create,
17
13
  createNode,
18
14
  define,
19
- remove,
20
15
  update,
21
- parse,
22
- lookup,
23
- set,
24
- get,
25
- log,
26
- keys
16
+ set
27
17
  }
package/iterate.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { isObject, exec, isFunction, isNumber, isString } from '@domql/utils'
4
4
  import { METHODS_EXL, checkIfKeyIsComponent, extendizeByKey, isVariant, overwrite } from './utils'
5
- import { isMethod } from '@domql/methods'
5
+ import { isMethod } from './methods'
6
6
 
7
7
  export const throughInitialExec = (element, exclude = {}) => {
8
8
  const { __ref: ref } = element