@domql/element 2.5.200 → 3.0.0

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 (140) hide show
  1. package/README.md +1 -1
  2. package/__tests__/checkIfOnUpdate.test.js +103 -0
  3. package/__tests__/children.test.js +213 -0
  4. package/__tests__/define.test.js +75 -0
  5. package/__tests__/inheritStateUpdates.test.js +79 -0
  6. package/__tests__/renderElement.test.js +131 -0
  7. package/__tests__/resetElement.test.js +44 -0
  8. package/__tests__/set.test.js +316 -0
  9. package/__tests__/throughExecProps.test.js +86 -0
  10. package/__tests__/throughInitialDefine.test.js +104 -0
  11. package/__tests__/throughInitialExec.test.js +92 -0
  12. package/__tests__/throughUpdatedDefine.test.js +92 -0
  13. package/__tests__/throughUpdatedExec.test.js +110 -0
  14. package/__tests__/tree.test.js +15 -0
  15. package/__tests__/update.test.js +253 -0
  16. package/children.js +105 -0
  17. package/create.js +125 -255
  18. package/dist/cjs/__tests__/checkIfOnUpdate.test.js +73 -0
  19. package/dist/cjs/__tests__/children.test.js +177 -0
  20. package/dist/cjs/__tests__/define.test.js +75 -0
  21. package/dist/cjs/__tests__/inheritStateUpdates.test.js +62 -0
  22. package/dist/cjs/__tests__/renderElement.test.js +138 -0
  23. package/dist/cjs/__tests__/resetElement.test.js +35 -0
  24. package/dist/cjs/__tests__/set.test.js +256 -0
  25. package/dist/cjs/__tests__/throughExecProps.test.js +62 -0
  26. package/dist/cjs/__tests__/throughInitialDefine.test.js +79 -0
  27. package/dist/cjs/__tests__/throughInitialExec.test.js +73 -0
  28. package/dist/cjs/__tests__/throughUpdatedDefine.test.js +69 -0
  29. package/dist/cjs/__tests__/throughUpdatedExec.test.js +84 -0
  30. package/dist/cjs/__tests__/tree.test.js +11 -0
  31. package/dist/cjs/__tests__/update.test.js +219 -0
  32. package/dist/cjs/children.js +87 -0
  33. package/dist/cjs/create.js +78 -177
  34. package/dist/cjs/iterate.js +29 -13
  35. package/dist/cjs/methods/set.js +27 -25
  36. package/dist/cjs/methods/v2.js +1 -5
  37. package/dist/cjs/mixins/attr.js +7 -6
  38. package/dist/cjs/mixins/index.js +0 -4
  39. package/dist/cjs/mixins/registry.js +7 -67
  40. package/dist/cjs/mixins/scope.js +1 -1
  41. package/dist/cjs/mixins/state.js +3 -4
  42. package/dist/cjs/mixins/text.js +3 -3
  43. package/dist/cjs/node.js +32 -22
  44. package/dist/cjs/set.js +112 -40
  45. package/dist/cjs/update.js +119 -64
  46. package/dist/cjs/utils/applyParam.js +2 -2
  47. package/dist/cjs/utils/index.js +8 -4
  48. package/dist/cjs/utils/onlyResolveExtends.js +4 -7
  49. package/dist/esm/__tests__/checkIfOnUpdate.test.js +73 -0
  50. package/dist/esm/__tests__/children.test.js +177 -0
  51. package/dist/esm/__tests__/define.test.js +53 -0
  52. package/dist/esm/__tests__/inheritStateUpdates.test.js +62 -0
  53. package/dist/esm/__tests__/renderElement.test.js +116 -0
  54. package/dist/esm/__tests__/resetElement.test.js +35 -0
  55. package/dist/esm/__tests__/set.test.js +256 -0
  56. package/dist/esm/__tests__/throughExecProps.test.js +62 -0
  57. package/dist/esm/__tests__/throughInitialDefine.test.js +79 -0
  58. package/dist/esm/__tests__/throughInitialExec.test.js +73 -0
  59. package/dist/esm/__tests__/throughUpdatedDefine.test.js +69 -0
  60. package/dist/esm/__tests__/throughUpdatedExec.test.js +84 -0
  61. package/dist/esm/__tests__/tree.test.js +11 -0
  62. package/dist/esm/__tests__/update.test.js +219 -0
  63. package/dist/esm/children.js +81 -0
  64. package/dist/esm/create.js +83 -188
  65. package/dist/esm/iterate.js +33 -16
  66. package/dist/esm/methods/set.js +6 -4
  67. package/dist/esm/methods/v2.js +1 -5
  68. package/dist/esm/mixins/attr.js +8 -7
  69. package/dist/esm/mixins/data.js +1 -1
  70. package/dist/esm/mixins/index.js +0 -4
  71. package/dist/esm/mixins/registry.js +7 -67
  72. package/dist/esm/mixins/scope.js +1 -1
  73. package/dist/esm/mixins/state.js +4 -5
  74. package/dist/esm/mixins/text.js +4 -7
  75. package/dist/esm/node.js +23 -23
  76. package/dist/esm/set.js +112 -40
  77. package/dist/esm/update.js +122 -68
  78. package/dist/esm/utils/applyParam.js +2 -2
  79. package/dist/esm/utils/index.js +4 -3
  80. package/dist/esm/utils/onlyResolveExtends.js +12 -8
  81. package/iterate.js +44 -26
  82. package/methods/set.js +5 -4
  83. package/methods/v2.js +5 -4
  84. package/mixins/attr.js +13 -7
  85. package/mixins/classList.js +7 -2
  86. package/mixins/data.js +1 -1
  87. package/mixins/index.js +1 -6
  88. package/mixins/registry.js +6 -53
  89. package/mixins/scope.js +1 -1
  90. package/mixins/state.js +4 -5
  91. package/mixins/text.js +4 -7
  92. package/node.js +31 -28
  93. package/package.json +7 -6
  94. package/set.js +129 -41
  95. package/update.js +169 -89
  96. package/utils/applyParam.js +7 -4
  97. package/utils/index.js +1 -3
  98. package/utils/onlyResolveExtends.js +27 -16
  99. package/cache/index.js +0 -3
  100. package/cache/options.js +0 -4
  101. package/dist/cjs/cache/index.js +0 -24
  102. package/dist/cjs/cache/options.js +0 -26
  103. package/dist/cjs/extend.js +0 -81
  104. package/dist/cjs/methods/index.js +0 -320
  105. package/dist/cjs/mixins/content.js +0 -67
  106. package/dist/cjs/props/create.js +0 -92
  107. package/dist/cjs/props/ignore.js +0 -24
  108. package/dist/cjs/props/index.js +0 -21
  109. package/dist/cjs/props/inherit.js +0 -51
  110. package/dist/cjs/props/update.js +0 -34
  111. package/dist/cjs/utils/component.js +0 -74
  112. package/dist/cjs/utils/extendUtils.js +0 -133
  113. package/dist/cjs/utils/object.js +0 -171
  114. package/dist/cjs/utils/propEvents.js +0 -39
  115. package/dist/esm/cache/index.js +0 -4
  116. package/dist/esm/cache/options.js +0 -6
  117. package/dist/esm/extend.js +0 -67
  118. package/dist/esm/methods/index.js +0 -300
  119. package/dist/esm/mixins/content.js +0 -47
  120. package/dist/esm/props/create.js +0 -72
  121. package/dist/esm/props/ignore.js +0 -4
  122. package/dist/esm/props/index.js +0 -4
  123. package/dist/esm/props/inherit.js +0 -31
  124. package/dist/esm/props/update.js +0 -14
  125. package/dist/esm/utils/component.js +0 -62
  126. package/dist/esm/utils/extendUtils.js +0 -113
  127. package/dist/esm/utils/object.js +0 -151
  128. package/dist/esm/utils/propEvents.js +0 -19
  129. package/extend.js +0 -90
  130. package/methods/index.js +0 -317
  131. package/mixins/content.js +0 -55
  132. package/props/create.js +0 -87
  133. package/props/ignore.js +0 -3
  134. package/props/index.js +0 -6
  135. package/props/inherit.js +0 -35
  136. package/props/update.js +0 -17
  137. package/utils/component.js +0 -68
  138. package/utils/extendUtils.js +0 -134
  139. package/utils/object.js +0 -172
  140. package/utils/propEvents.js +0 -19
@@ -0,0 +1,177 @@
1
+ var import_globals = require("@jest/globals");
2
+ var import_children = require("../children");
3
+ describe("children", () => {
4
+ let element, node;
5
+ beforeEach(() => {
6
+ element = {
7
+ __ref: {},
8
+ state: {},
9
+ props: {},
10
+ call: import_globals.jest.fn(),
11
+ removeContent: import_globals.jest.fn(),
12
+ content: null
13
+ };
14
+ node = {};
15
+ });
16
+ it("handles null/undefined params", async () => {
17
+ const result = await (0, import_children.setChildren)(null, element, node);
18
+ expect(result).toBeUndefined();
19
+ });
20
+ it("handles direct string children", async () => {
21
+ const result = await (0, import_children.setChildren)("Hello World", element, node);
22
+ expect(result).toEqual({ tag: "fragment", 0: { text: "Hello World" } });
23
+ });
24
+ it("handles numeric children", async () => {
25
+ const result = await (0, import_children.setChildren)(42, element, node);
26
+ expect(result).toEqual({ tag: "fragment", 0: { text: 42 } });
27
+ });
28
+ it("handles array of primitive values with childrenAs prop", async () => {
29
+ const result = await (0, import_children.setChildren)(["one", "two"], element, node);
30
+ expect(result).toEqual({
31
+ tag: "fragment",
32
+ 0: { text: "one" },
33
+ 1: { text: "two" }
34
+ });
35
+ });
36
+ it("handles array of primitive values with childrenAs state", async () => {
37
+ element.props.childrenAs = "state";
38
+ const result = await (0, import_children.setChildren)(["one", "two"], element, node);
39
+ expect(result).toEqual({
40
+ tag: "fragment",
41
+ 0: { state: { value: "one" } },
42
+ 1: { state: { value: "two" } }
43
+ });
44
+ });
45
+ it("caches children and detects changes", async () => {
46
+ const children1 = [{ id: 1 }, { id: 2 }];
47
+ const children2 = [{ id: 1 }, { id: 2 }];
48
+ const children3 = [{ id: 1 }, { id: 3 }];
49
+ await (0, import_children.setChildren)(children1, element, node);
50
+ expect(element.__ref.__childrenCache).toEqual(children1);
51
+ expect(element.__ref.__noChildrenDifference).toBeUndefined();
52
+ await (0, import_children.setChildren)(children2, element, node);
53
+ expect(element.__ref.__noChildrenDifference).toBe(true);
54
+ await (0, import_children.setChildren)(children3, element, node);
55
+ expect(element.__ref.__noChildrenDifference).toBeUndefined();
56
+ expect(element.__ref.__childrenCache).toEqual(children3);
57
+ });
58
+ it("handles mixed React and normal components", async () => {
59
+ const mixedChildren = [
60
+ { type: "div", text: "Normal" },
61
+ { $$typeof: Symbol("react") },
62
+ { type: "span", text: "Another" }
63
+ ];
64
+ await (0, import_children.setChildren)(mixedChildren, element, node);
65
+ expect(element.call).toHaveBeenCalledWith(
66
+ "renderReact",
67
+ [mixedChildren[1]],
68
+ element
69
+ );
70
+ });
71
+ it("handles state-based children", async () => {
72
+ element.state = {
73
+ items: ["a", "b"],
74
+ parse: () => ["parsed a", "parsed b"]
75
+ };
76
+ const result = await (0, import_children.setChildren)("state", element, node);
77
+ expect(result).toEqual({
78
+ tag: "fragment",
79
+ 0: { text: "parsed a" },
80
+ 1: { text: "parsed b" }
81
+ });
82
+ });
83
+ it("handles async function parameters", async () => {
84
+ const asyncParam = async () => ["async1", "async2"];
85
+ const result = await (0, import_children.setChildren)(asyncParam, element, node);
86
+ expect(result).toEqual({
87
+ tag: "fragment",
88
+ 0: { text: "async1" },
89
+ 1: { text: "async2" }
90
+ });
91
+ });
92
+ it("handles nested object structures", async () => {
93
+ const nestedChildren = {
94
+ header: { text: "Title" },
95
+ content: {
96
+ nested: { text: "Content" }
97
+ }
98
+ };
99
+ const result = await (0, import_children.setChildren)(nestedChildren, element, node);
100
+ expect(result).toEqual({
101
+ tag: "fragment",
102
+ 0: { text: "Title" },
103
+ 1: { nested: { text: "Content" } }
104
+ });
105
+ });
106
+ it("handles empty arrays and objects", async () => {
107
+ let result = await (0, import_children.setChildren)([], element, node);
108
+ expect(result).toEqual({
109
+ tag: "fragment"
110
+ });
111
+ result = await (0, import_children.setChildren)({}, element, node);
112
+ expect(result).toEqual({
113
+ tag: "fragment"
114
+ });
115
+ });
116
+ it("handles falsy values in arrays", async () => {
117
+ const result = await (0, import_children.setChildren)(
118
+ [null, void 0, false, 0, ""],
119
+ element,
120
+ node
121
+ );
122
+ expect(result).toEqual({
123
+ tag: "fragment",
124
+ 3: { text: 0 },
125
+ 4: { text: "" }
126
+ });
127
+ });
128
+ it("handles React components with falsy values in array", async () => {
129
+ const mixedChildren = [
130
+ null,
131
+ { $$typeof: Symbol("react") },
132
+ void 0,
133
+ { $$typeof: Symbol("react") },
134
+ false
135
+ ];
136
+ await (0, import_children.setChildren)(mixedChildren, element, node);
137
+ expect(element.call).toHaveBeenCalledWith(
138
+ "renderReact",
139
+ [mixedChildren[1], mixedChildren[3]],
140
+ element
141
+ );
142
+ });
143
+ it("handles nested state parsing", async () => {
144
+ element.state = {
145
+ nested: {
146
+ items: ["c", "d"]
147
+ }
148
+ };
149
+ element.state.nested.__proto__.parse = () => ["parsed c", "parsed d"];
150
+ const result = await (0, import_children.setChildren)("nested", element, node);
151
+ expect(result).toEqual({
152
+ tag: "fragment",
153
+ 0: { state: ["c", "d"] }
154
+ });
155
+ });
156
+ it("handles mixed state and regular objects", async () => {
157
+ element.state = {
158
+ header: { parse: () => "Header" },
159
+ footer: { parse: () => "Footer" }
160
+ };
161
+ const result = await (0, import_children.setChildren)(
162
+ {
163
+ header: "header",
164
+ content: { text: "Content" },
165
+ footer: "footer"
166
+ },
167
+ element,
168
+ node
169
+ );
170
+ expect(result).toEqual({
171
+ tag: "fragment",
172
+ 0: { text: "header" },
173
+ 1: { text: "Content" },
174
+ 2: { text: "footer" }
175
+ });
176
+ });
177
+ });
@@ -0,0 +1,75 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var import_define = __toESM(require("../define"), 1);
24
+ var import_mixins = require("../mixins");
25
+ describe("default function (registry updater)", () => {
26
+ let originalRegistry;
27
+ beforeEach(() => {
28
+ originalRegistry = { ...import_mixins.REGISTRY };
29
+ });
30
+ afterEach(() => {
31
+ Object.keys(import_mixins.REGISTRY).forEach((key) => {
32
+ import_mixins.REGISTRY[key] = originalRegistry[key];
33
+ });
34
+ });
35
+ it("should add new params to REGISTRY when overwrite is true", () => {
36
+ const params = { newKey: "newValue", anotherKey: "anotherValue" };
37
+ const options = { overwrite: true };
38
+ (0, import_define.default)(params, options);
39
+ expect(import_mixins.REGISTRY.newKey).toBe("newValue");
40
+ expect(import_mixins.REGISTRY.anotherKey).toBe("anotherValue");
41
+ });
42
+ it("should not modify REGISTRY when trying to overwrite existing keys without overwrite option", () => {
43
+ const params = { attr: "newValue", text: "newText" };
44
+ try {
45
+ (0, import_define.default)(params);
46
+ } catch (e) {
47
+ }
48
+ expect(import_mixins.REGISTRY.attr).toBe(originalRegistry.attr);
49
+ expect(import_mixins.REGISTRY.text).toBe(originalRegistry.text);
50
+ });
51
+ it("should overwrite existing keys when overwrite is true", () => {
52
+ const params = { attr: "newValue", text: "newText" };
53
+ const options = { overwrite: true };
54
+ (0, import_define.default)(params, options);
55
+ expect(import_mixins.REGISTRY.attr).toBe("newValue");
56
+ expect(import_mixins.REGISTRY.text).toBe("newText");
57
+ });
58
+ it("should handle empty params object without errors", () => {
59
+ const params = {};
60
+ const options = { overwrite: true };
61
+ expect(() => (0, import_define.default)(params, options)).not.toThrow();
62
+ expect(import_mixins.REGISTRY).toEqual(originalRegistry);
63
+ });
64
+ it("should handle empty options object without errors", () => {
65
+ const params = { newKey: "newValue" };
66
+ expect(() => (0, import_define.default)(params, {})).not.toThrow();
67
+ expect(import_mixins.REGISTRY.newKey).toBe("newValue");
68
+ });
69
+ it("should not add new keys when params is empty", () => {
70
+ const params = {};
71
+ const options = { overwrite: true };
72
+ (0, import_define.default)(params, options);
73
+ expect(import_mixins.REGISTRY).toEqual(originalRegistry);
74
+ });
75
+ });
@@ -0,0 +1,62 @@
1
+ var import_update = require("../update");
2
+ describe("update() with inheritStateUpdates", () => {
3
+ let element, options;
4
+ beforeEach(() => {
5
+ element = {
6
+ __ref: {
7
+ __state: null,
8
+ __hasRootState: false,
9
+ __execProps: {},
10
+ __props: []
11
+ },
12
+ state: {
13
+ calculated: 42,
14
+ set: () => {
15
+ return true;
16
+ }
17
+ },
18
+ parent: {
19
+ state: { baseState: true },
20
+ props: {}
21
+ },
22
+ props: {},
23
+ key: "testKey"
24
+ };
25
+ options = {};
26
+ });
27
+ it("processes full update flow when state is inherited", async () => {
28
+ await import_update.update.call(element, { props: { newProp: true } }, options);
29
+ expect(element.props.newProp).toBe(true);
30
+ expect(element.state.baseState).toBe(true);
31
+ });
32
+ it("maintains state when preventInheritedStateUpdate=true", async () => {
33
+ options.preventInheritedStateUpdate = true;
34
+ element.state = { existing: "state" };
35
+ await import_update.update.call(element, {}, options);
36
+ expect(element.state).toEqual({ baseState: true });
37
+ });
38
+ it("overwrites state with function result", async () => {
39
+ element.__ref.__state = () => ({ calculated: 42 });
40
+ options.execStateFunction = true;
41
+ options.stateFunctionOverwrite = true;
42
+ await import_update.update.call(element, {}, options);
43
+ expect(element.state.calculated).toEqual(42);
44
+ });
45
+ it("preserves state when beforeStateUpdate rejects", async () => {
46
+ element.props.onBeforeStateUpdate = () => false;
47
+ await import_update.update.call(element, { props: { shouldChange: true } }, options);
48
+ expect(element.state).toEqual({ baseState: true });
49
+ expect(element.props.shouldChange).toBe(true);
50
+ });
51
+ it("reflects parent state updates", async () => {
52
+ element.parent.state = { updatedParentState: true };
53
+ await import_update.update.call(element, {}, options);
54
+ expect(element.state.updatedParentState).toBe(true);
55
+ });
56
+ it("preserves local state when __hasRootState=true", async () => {
57
+ element.__ref.__hasRootState = true;
58
+ element.state = { local: "data" };
59
+ await import_update.update.call(element, {}, options);
60
+ expect(element.state.local).toBe("data");
61
+ });
62
+ });
@@ -0,0 +1,138 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var import_globals = require("@jest/globals");
24
+ describe("create()", () => {
25
+ let props;
26
+ let parent;
27
+ const OLD_ENV = process.env;
28
+ beforeEach(() => {
29
+ props = {
30
+ __ref: { __if: false, path: [], __skipCreate: true },
31
+ key: "testKey",
32
+ context: {
33
+ defaultExtends: {},
34
+ define: ["test"]
35
+ },
36
+ scope: "props",
37
+ define: ["test"]
38
+ };
39
+ parent = {
40
+ testKey: "parentTestKey",
41
+ key: "parentKey"
42
+ };
43
+ import_globals.jest.resetModules();
44
+ process.env = { ...OLD_ENV };
45
+ });
46
+ afterAll(() => {
47
+ process.env = OLD_ENV;
48
+ });
49
+ test("should execute onlyResolveExtends when __skipCreate is true", async () => {
50
+ props.__ref.__skipCreate = true;
51
+ props.scope = void 0;
52
+ const { create } = await import("../create");
53
+ await create(props, parent, "passedKey", {
54
+ onlyResolveExtends: true,
55
+ define: ["test"]
56
+ });
57
+ expect(parent.__ref).toBeUndefined();
58
+ expect(parent.passedKey).toBe(props.__ref.parent.passedKey);
59
+ });
60
+ test("should execute onlyResolveExtends when __ref.__if is true", async () => {
61
+ props.__ref.__if = true;
62
+ props.scope = "state";
63
+ const { create } = await import("../create");
64
+ await create(props, parent, "passedKey", {
65
+ onlyResolveExtends: true,
66
+ define: ["test"]
67
+ });
68
+ expect(parent.__ref).toBeUndefined();
69
+ expect(parent.passedKey).toBe(props.__ref.parent.passedKey);
70
+ });
71
+ test("should execute onlyResolveExtends when scope is not state", async () => {
72
+ process.env.NODE_ENV = "prod";
73
+ props.__ref = void 0;
74
+ const { create } = await import("../create");
75
+ await create(props, parent, "passedKey", { onlyResolveExtends: true });
76
+ expect(parent.__ref).toBeUndefined();
77
+ expect(parent.passedKey).toBe(props.__ref.parent.passedKey);
78
+ });
79
+ test("should execute catch statement when __ref is undefined", async () => {
80
+ process.env.NODE_ENV = "prod";
81
+ props.__ref = void 0;
82
+ const { create } = await import("../create");
83
+ await create(props, parent, "passedKey");
84
+ expect(parent.__ref).toBeUndefined();
85
+ expect(parent.passedKey).toBe(props.__ref.parent.passedKey);
86
+ });
87
+ test("should attaches element to parent when ref.__if is false", async () => {
88
+ process.env.NODE_ENV = "prod";
89
+ const { create } = await import("../create");
90
+ await create(props, parent, "passedKey");
91
+ expect(parent.__ref).toBeUndefined();
92
+ expect(parent.passedKey).toBe(props.__ref.parent.passedKey);
93
+ });
94
+ test("should attach element to parent when ref.__if is true", async () => {
95
+ process.env.NODE_ENV = "prod";
96
+ props.__if = true;
97
+ const { create } = await import("../create");
98
+ await create(props, parent, "passedKey");
99
+ expect(parent.testKey).toBe("parentTestKey");
100
+ expect(parent.passedKey).toBe(props.__ref.parent.passedKey);
101
+ });
102
+ test("skips createNestedChild when __uniqId exists", async () => {
103
+ process.env.NODE_ENV = "prod";
104
+ props.__ref = { __uniqId: "existing-id", path: [] };
105
+ const { create } = await import("../create");
106
+ await create(props, {}, "passedKey");
107
+ expect(props.__ref.__uniqId).toBeDefined();
108
+ });
109
+ test("skips createNestedChild when infinite loop detected", async () => {
110
+ process.env.NODE_ENV = "prod";
111
+ props.__ref = { path: ["loop-path"], __uniqId: void 0 };
112
+ const { create } = await import("../create");
113
+ await create(props, {}, "passedKey");
114
+ expect(props.__ref.__uniqId).toBeDefined();
115
+ });
116
+ test("should modifies path containing ComponentsGrid", async () => {
117
+ process.env.NODE_ENV = "prod";
118
+ props.__ref = { path: ["ComponentsGrid", "x", "y", "z"] };
119
+ const { create } = await import("../create");
120
+ await create(props, {}, ["ComponentsGrid", "x", "y", "z"]);
121
+ expect(props.__ref.path).toEqual(["ComponentsGrid,x,y,z"]);
122
+ });
123
+ test("should modifies path containing demoComponent", async () => {
124
+ process.env.NODE_ENV = "prod";
125
+ props.__ref = { path: ["demoComponent", "a", "b", "c"] };
126
+ const { create } = await import("../create");
127
+ await create(props, {}, ["demoComponent", "a", "b", "c"]);
128
+ expect(props.__ref.path).toEqual(["demoComponent,a,b,c"]);
129
+ });
130
+ test("uses element.key when key property is missing", async () => {
131
+ process.env.NODE_ENV = "prod";
132
+ props.__ref = { __if: false, path: [] };
133
+ props.key = "fallbackKey";
134
+ const { create } = await import("../create");
135
+ await create(props, parent, null);
136
+ expect(props.__ref.parent.fallbackKey).toBeDefined();
137
+ });
138
+ });
@@ -0,0 +1,35 @@
1
+ var import_set = require("../set");
2
+ describe("resetContent", () => {
3
+ let element, ref;
4
+ beforeEach(() => {
5
+ ref = {
6
+ contentElementKey: "content"
7
+ };
8
+ element = {
9
+ __ref: ref,
10
+ content: { node: document.createElement("div") },
11
+ node: document.createElement("div"),
12
+ context: {}
13
+ };
14
+ });
15
+ it("should update contentElementKey from options", async () => {
16
+ await (0, import_set.resetContent)({}, element, { contentElementKey: "mainContent" });
17
+ expect(ref.contentElementKey).toBe("mainContent");
18
+ expect(element.mainContent).toBeDefined();
19
+ });
20
+ it("should merge options correctly", async () => {
21
+ await (0, import_set.resetContent)({}, element, { customOption: true });
22
+ expect(element.content).toEqual(
23
+ expect.objectContaining({
24
+ // Verify options merging through observable behavior
25
+ // (this assertion pattern would need actual create() implementation details)
26
+ })
27
+ );
28
+ });
29
+ it("should maintain context through reset", async () => {
30
+ const originalContext = element.context;
31
+ await (0, import_set.resetContent)({}, element, {});
32
+ expect(element.context).toBe(originalContext);
33
+ expect(element.content.context).toBe(originalContext);
34
+ });
35
+ });