@domql/element 2.5.0 → 2.5.2

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
@@ -23,7 +23,8 @@ import {
23
23
  is,
24
24
  isNode,
25
25
  isUndefined,
26
- generateKey
26
+ generateKey,
27
+ deepClone
27
28
  } from '@domql/utils'
28
29
 
29
30
  import OPTIONS from './cache/options'
@@ -55,6 +56,9 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
55
56
 
56
57
  const ref = addRef(element, parent, key)
57
58
 
59
+ // assign initial props
60
+ ref.__initialProps = deepClone(element.props, [])
61
+
58
62
  // assign context
59
63
  applyContext(element, parent, options)
60
64
 
@@ -68,7 +72,7 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
68
72
 
69
73
  // Only resolve extends, skip everything else
70
74
  if (options.onlyResolveExtends) {
71
- return onlyResolveExtends(element, parent, options)
75
+ return onlyResolveExtends(element, parent, key, options)
72
76
  }
73
77
 
74
78
  replaceOptions(element, parent, options)
@@ -281,7 +285,7 @@ const addCaching = (element, parent) => {
281
285
  }
282
286
  }
283
287
 
284
- const onlyResolveExtends = (element, parent, options) => {
288
+ const onlyResolveExtends = (element, parent, key, options) => {
285
289
  const { __ref } = element
286
290
  element.tag = detectTag(element)
287
291
 
@@ -317,6 +321,8 @@ const onlyResolveExtends = (element, parent, options) => {
317
321
  }
318
322
  }
319
323
 
324
+ parent[key || element.key] = element
325
+
320
326
  delete element.update
321
327
  delete element.__element
322
328
 
@@ -57,12 +57,13 @@ const create = (element, parent, key, options = import_options.default.create ||
57
57
  parent = redefineParent(element, parent, key);
58
58
  key = createKey(element, parent, key);
59
59
  const ref = addRef(element, parent, key);
60
+ ref.__initialProps = (0, import_utils.deepClone)(element.props, []);
60
61
  applyContext(element, parent, options);
61
62
  (0, import_component.applyComponentFromContext)(element, parent, options);
62
63
  (0, import_extend.applyExtend)(element, parent, options);
63
64
  element.key = key;
64
65
  if (options.onlyResolveExtends) {
65
- return onlyResolveExtends(element, parent, options);
66
+ return onlyResolveExtends(element, parent, key, options);
66
67
  }
67
68
  replaceOptions(element, parent, options);
68
69
  addCaching(element, parent);
@@ -224,7 +225,7 @@ const addCaching = (element, parent) => {
224
225
  ref.__path = parentRef.__path.concat(element.key);
225
226
  }
226
227
  };
227
- const onlyResolveExtends = (element, parent, options) => {
228
+ const onlyResolveExtends = (element, parent, key, options) => {
228
229
  const { __ref } = element;
229
230
  element.tag = (0, import_render.detectTag)(element);
230
231
  if (!__ref.__exec)
@@ -250,6 +251,7 @@ const onlyResolveExtends = (element, parent, options) => {
250
251
  create((0, import_utils.exec)(prop, element), element, param, options);
251
252
  }
252
253
  }
254
+ parent[key || element.key] = element;
253
255
  delete element.update;
254
256
  delete element.__element;
255
257
  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.5.0",
3
+ "version": "2.5.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -31,7 +31,7 @@
31
31
  "@domql/state": "latest",
32
32
  "@domql/utils": "latest"
33
33
  },
34
- "gitHead": "1caef4529af5d71b96bac356e3420a686df28052",
34
+ "gitHead": "e5952db705e332f062e2e78113d620bd48ba16d9",
35
35
  "devDependencies": {
36
36
  "@babel/core": "^7.12.0"
37
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.