domql 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.
@@ -0,0 +1,100 @@
1
+ import moduleExports from '../index'
2
+ const { create } = moduleExports
3
+
4
+ describe('create', () => {
5
+ it('should execute on.complete handler and modify state', async () => {
6
+ const element = {
7
+ on: {
8
+ complete: async (el, state) => {
9
+ state.ranComplete = true
10
+ }
11
+ },
12
+ state: {},
13
+ context: {}
14
+ }
15
+
16
+ await create(element, {}, 'key', {})
17
+ expect(element.state.ranComplete).toBe(true)
18
+ })
19
+
20
+ it('should execute props.onComplete and modify context', async () => {
21
+ const element = {
22
+ props: {
23
+ onComplete: async (el, state, context) => {
24
+ context.ranPropsComplete = true
25
+ }
26
+ },
27
+ state: {},
28
+ context: {}
29
+ }
30
+
31
+ await create(element, {}, 'key', {})
32
+ expect(element.context.ranPropsComplete).toBe(true)
33
+ })
34
+
35
+ it('should execute initInspect and modify options', async () => {
36
+ const options = {}
37
+ const element = {
38
+ on: {
39
+ initInspect: async (el, state, context, opts) => {
40
+ opts.inspected = true
41
+ }
42
+ },
43
+ state: {},
44
+ context: {}
45
+ }
46
+
47
+ await create(element, {}, 'key', options)
48
+ expect(options.inspected).toBe(true)
49
+ })
50
+
51
+ it('should execute initSync and modify element', async () => {
52
+ const element = {
53
+ on: {
54
+ initSync: async el => {
55
+ el.synced = true
56
+ }
57
+ },
58
+ state: {},
59
+ context: {}
60
+ }
61
+
62
+ const result = await create(element, {}, 'key', {})
63
+ expect(result.synced).toBeUndefined()
64
+ })
65
+
66
+ it('should handle multiple lifecycle handlers', async () => {
67
+ const options = {}
68
+ const element = {
69
+ on: {
70
+ complete: async el => {
71
+ el.ordered = '1'
72
+ },
73
+ initSync: async el => {
74
+ el.ordered += '2'
75
+ }
76
+ },
77
+ props: {
78
+ onComplete: async el => {
79
+ el.ordered += '3'
80
+ }
81
+ },
82
+ state: {},
83
+ context: {}
84
+ }
85
+
86
+ const result = await create(element, {}, 'key', options)
87
+ expect(result.ordered).toBe('13')
88
+ })
89
+
90
+ it('should not clean up __ref when keepRef=false', async () => {
91
+ const element = {
92
+ __ref: { some: 'data' },
93
+ state: {},
94
+ context: {}
95
+ }
96
+
97
+ await create(element, {}, 'key', { keepRef: false })
98
+ expect(element.__ref).toBeDefined()
99
+ })
100
+ })
package/dist/cjs/index.js CHANGED
@@ -24,15 +24,48 @@ module.exports = __toCommonJS(index_exports);
24
24
  var import_element = require("@domql/element");
25
25
  const create = async (element, parent, key, options) => {
26
26
  var _a, _b, _c, _d, _e;
27
- const domqlElement = await (import_element.create.default || import_element.create)(element, parent, key, options);
27
+ const domqlElement = await (import_element.create.default || import_element.create)(
28
+ element,
29
+ parent,
30
+ key,
31
+ options
32
+ );
28
33
  const complete = (_a = domqlElement.on) == null ? void 0 : _a.complete;
29
- if (complete) await domqlElement.on.complete(element, element.state, element.context, options);
34
+ if (complete) {
35
+ await domqlElement.on.complete(
36
+ element,
37
+ element.state,
38
+ element.context,
39
+ options
40
+ );
41
+ }
30
42
  const onComplete = (_b = domqlElement.props) == null ? void 0 : _b.onComplete;
31
- if (onComplete) await ((_c = domqlElement.props) == null ? void 0 : _c.onComplete(element, element.state, element.context, options));
43
+ if (onComplete) {
44
+ await ((_c = domqlElement.props) == null ? void 0 : _c.onComplete(
45
+ element,
46
+ element.state,
47
+ element.context,
48
+ options
49
+ ));
50
+ }
32
51
  const initInspect = (_d = domqlElement.on) == null ? void 0 : _d.initInspect;
33
- if (initInspect) await domqlElement.on.initInspect(element, element.state, element.context, options);
52
+ if (initInspect) {
53
+ await domqlElement.on.initInspect(
54
+ element,
55
+ element.state,
56
+ element.context,
57
+ options
58
+ );
59
+ }
34
60
  const initSync = (_e = domqlElement.on) == null ? void 0 : _e.initSync;
35
- if (initSync) await domqlElement.on.initSync(element, element.state, element.context, options);
61
+ if (initSync) {
62
+ await domqlElement.on.initSync(
63
+ element,
64
+ element.state,
65
+ element.context,
66
+ options
67
+ );
68
+ }
36
69
  return domqlElement;
37
70
  };
38
71
  var index_default = {
package/dist/esm/index.js CHANGED
@@ -1,15 +1,48 @@
1
1
  import { TREE, create as createElement } from "@domql/element";
2
2
  const create = async (element, parent, key, options) => {
3
3
  var _a, _b, _c, _d, _e;
4
- const domqlElement = await (createElement.default || createElement)(element, parent, key, options);
4
+ const domqlElement = await (createElement.default || createElement)(
5
+ element,
6
+ parent,
7
+ key,
8
+ options
9
+ );
5
10
  const complete = (_a = domqlElement.on) == null ? void 0 : _a.complete;
6
- if (complete) await domqlElement.on.complete(element, element.state, element.context, options);
11
+ if (complete) {
12
+ await domqlElement.on.complete(
13
+ element,
14
+ element.state,
15
+ element.context,
16
+ options
17
+ );
18
+ }
7
19
  const onComplete = (_b = domqlElement.props) == null ? void 0 : _b.onComplete;
8
- if (onComplete) await ((_c = domqlElement.props) == null ? void 0 : _c.onComplete(element, element.state, element.context, options));
20
+ if (onComplete) {
21
+ await ((_c = domqlElement.props) == null ? void 0 : _c.onComplete(
22
+ element,
23
+ element.state,
24
+ element.context,
25
+ options
26
+ ));
27
+ }
9
28
  const initInspect = (_d = domqlElement.on) == null ? void 0 : _d.initInspect;
10
- if (initInspect) await domqlElement.on.initInspect(element, element.state, element.context, options);
29
+ if (initInspect) {
30
+ await domqlElement.on.initInspect(
31
+ element,
32
+ element.state,
33
+ element.context,
34
+ options
35
+ );
36
+ }
11
37
  const initSync = (_e = domqlElement.on) == null ? void 0 : _e.initSync;
12
- if (initSync) await domqlElement.on.initSync(element, element.state, element.context, options);
38
+ if (initSync) {
39
+ await domqlElement.on.initSync(
40
+ element,
41
+ element.state,
42
+ element.context,
43
+ options
44
+ );
45
+ }
13
46
  return domqlElement;
14
47
  };
15
48
  var index_default = {
package/index.js CHANGED
@@ -3,18 +3,51 @@
3
3
  import { TREE, create as createElement } from '@domql/element'
4
4
 
5
5
  const create = async (element, parent, key, options) => {
6
- const domqlElement = await (createElement.default || createElement)(element, parent, key, options)
6
+ const domqlElement = await (createElement.default || createElement)(
7
+ element,
8
+ parent,
9
+ key,
10
+ options
11
+ )
7
12
 
8
13
  const complete = domqlElement.on?.complete
9
- if (complete) await domqlElement.on.complete(element, element.state, element.context, options)
14
+ if (complete) {
15
+ await domqlElement.on.complete(
16
+ element,
17
+ element.state,
18
+ element.context,
19
+ options
20
+ )
21
+ }
10
22
  const onComplete = domqlElement.props?.onComplete
11
- if (onComplete) await domqlElement.props?.onComplete(element, element.state, element.context, options)
23
+ if (onComplete) {
24
+ await domqlElement.props?.onComplete(
25
+ element,
26
+ element.state,
27
+ element.context,
28
+ options
29
+ )
30
+ }
12
31
 
13
32
  const initInspect = domqlElement.on?.initInspect
14
- if (initInspect) await domqlElement.on.initInspect(element, element.state, element.context, options)
33
+ if (initInspect) {
34
+ await domqlElement.on.initInspect(
35
+ element,
36
+ element.state,
37
+ element.context,
38
+ options
39
+ )
40
+ }
15
41
 
16
42
  const initSync = domqlElement.on?.initSync
17
- if (initSync) await domqlElement.on.initSync(element, element.state, element.context, options)
43
+ if (initSync) {
44
+ await domqlElement.on.initSync(
45
+ element,
46
+ element.state,
47
+ element.context,
48
+ options
49
+ )
50
+ }
18
51
 
19
52
  return domqlElement
20
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domql",
3
- "version": "2.5.200",
3
+ "version": "3.0.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -25,11 +25,11 @@
25
25
  "prepublish": "rimraf -I dist && npm run build && npm run copy:package:cjs"
26
26
  },
27
27
  "dependencies": {
28
- "@domql/element": "^2.5.200",
29
- "@domql/event": "^2.5.200",
30
- "@domql/render": "^2.5.200",
31
- "@domql/state": "^2.5.200",
32
- "@domql/utils": "^2.5.200"
28
+ "@domql/element": "^3.0.0",
29
+ "@domql/event": "^3.0.0",
30
+ "@domql/render": "^3.0.0",
31
+ "@domql/state": "^3.0.0",
32
+ "@domql/utils": "^3.0.0"
33
33
  },
34
- "gitHead": "0afb63ec375f0526f47ff300885de393138b01e8"
34
+ "gitHead": "bcbdc271a602b958de6a60ab387ea7715a935dc1"
35
35
  }