@domql/element 2.4.12 → 2.5.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.
package/create.js CHANGED
@@ -4,8 +4,7 @@ import createNode from './node'
4
4
  import { ROOT } from './tree'
5
5
  import { TAGS } from '@domql/registry'
6
6
  import { triggerEventOn } from '@domql/event'
7
- import { appendNode, assignNode } from '@domql/render'
8
- import { cacheNode, detectTag } from '@domql/node'
7
+ import { appendNode, assignNode, cacheNode, detectTag } from '@domql/render'
9
8
  import { createState } from '@domql/state'
10
9
 
11
10
  import { isMethod } from './methods'
@@ -56,6 +55,9 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
56
55
 
57
56
  const ref = addRef(element, parent, key)
58
57
 
58
+ // assign initial props
59
+ ref.__initialProps = deepClone(element.props, [])
60
+
59
61
  // assign context
60
62
  applyContext(element, parent, options)
61
63
 
@@ -69,7 +71,7 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
69
71
 
70
72
  // Only resolve extends, skip everything else
71
73
  if (options.onlyResolveExtends) {
72
- return onlyResolveExtends(element, parent, options)
74
+ return onlyResolveExtends(element, parent, key, options)
73
75
  }
74
76
 
75
77
  replaceOptions(element, parent, options)
@@ -282,7 +284,7 @@ const addCaching = (element, parent) => {
282
284
  }
283
285
  }
284
286
 
285
- const onlyResolveExtends = (element, parent, options) => {
287
+ const onlyResolveExtends = (element, parent, key, options) => {
286
288
  const { __ref } = element
287
289
  element.tag = detectTag(element)
288
290
 
@@ -318,6 +320,8 @@ const onlyResolveExtends = (element, parent, options) => {
318
320
  }
319
321
  }
320
322
 
323
+ parent[key || element.key] = element
324
+
321
325
  delete element.update
322
326
  delete element.__element
323
327
 
@@ -58,12 +58,13 @@ const create = (element, parent, key, options = import_options.default.create ||
58
58
  parent = redefineParent(element, parent, key);
59
59
  key = createKey(element, parent, key);
60
60
  const ref = addRef(element, parent, key);
61
+ ref.__initialProps = deepClone(element.props, []);
61
62
  applyContext(element, parent, options);
62
63
  (0, import_component.applyComponentFromContext)(element, parent, options);
63
64
  (0, import_extend.applyExtend)(element, parent, options);
64
65
  element.key = key;
65
66
  if (options.onlyResolveExtends) {
66
- return onlyResolveExtends(element, parent, options);
67
+ return onlyResolveExtends(element, parent, key, options);
67
68
  }
68
69
  replaceOptions(element, parent, options);
69
70
  addCaching(element, parent);
@@ -225,7 +226,7 @@ const addCaching = (element, parent) => {
225
226
  ref.__path = parentRef.__path.concat(element.key);
226
227
  }
227
228
  };
228
- const onlyResolveExtends = (element, parent, options) => {
229
+ const onlyResolveExtends = (element, parent, key, options) => {
229
230
  const { __ref } = element;
230
231
  element.tag = (0, import_node2.detectTag)(element);
231
232
  if (!__ref.__exec)
@@ -251,6 +252,7 @@ const onlyResolveExtends = (element, parent, options) => {
251
252
  create((0, import_utils.exec)(prop, element), element, param, options);
252
253
  }
253
254
  }
255
+ parent[key || element.key] = element;
254
256
  delete element.update;
255
257
  delete element.__element;
256
258
  delete element.props.update;
@@ -30,9 +30,9 @@ const applyExtend = (element, parent, options = {}) => {
30
30
  let { extend, props, context, __ref } = element;
31
31
  const COMPONENTS = context && context.components || options.components;
32
32
  if ((0, import_utils.isString)(extend)) {
33
- if (COMPONENTS && COMPONENTS[extend])
33
+ if (COMPONENTS && COMPONENTS[extend]) {
34
34
  extend = COMPONENTS[extend];
35
- else {
35
+ } else {
36
36
  if (ENV !== "test" || ENV !== "development") {
37
37
  console.warn("Extend is string but component was not found:", extend);
38
38
  }
package/extend.js CHANGED
@@ -22,11 +22,13 @@ export const applyExtend = (element, parent, options = {}) => {
22
22
 
23
23
  const COMPONENTS = (context && context.components) || options.components
24
24
  if (isString(extend)) {
25
- if (COMPONENTS && COMPONENTS[extend]) extend = COMPONENTS[extend]
26
- else {
25
+ if (COMPONENTS && COMPONENTS[extend]) {
26
+ extend = COMPONENTS[extend]
27
+ } else {
27
28
  if (ENV !== 'test' || ENV !== 'development') {
28
29
  console.warn('Extend is string but component was not found:', extend)
29
- } extend = {}
30
+ }
31
+ extend = {}
30
32
  }
31
33
  }
32
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "2.4.12",
3
+ "version": "2.5.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -26,11 +26,12 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@domql/event": "latest",
29
+ "@domql/node": "latest",
29
30
  "@domql/render": "latest",
30
31
  "@domql/state": "latest",
31
32
  "@domql/utils": "latest"
32
33
  },
33
- "gitHead": "fb655eb1dbbde28cb1b843f13aad21afcfcece40",
34
+ "gitHead": "e5952db705e332f062e2e78113d620bd48ba16d9",
34
35
  "devDependencies": {
35
36
  "@babel/core": "^7.12.0"
36
37
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 symbo.ls
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.