@domql/utils 2.5.148 → 2.5.150

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/component.js CHANGED
@@ -28,6 +28,7 @@ export const checkIfKeyIsProperty = (key) => {
28
28
  }
29
29
 
30
30
  export const addAdditionalExtend = (newExtend, element) => {
31
+ if (!newExtend) return element
31
32
  const { extend: elementExtend } = element
32
33
  const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend]
33
34
  const receivedArray = isArray(newExtend) ? newExtend : [newExtend]
@@ -36,8 +37,23 @@ export const addAdditionalExtend = (newExtend, element) => {
36
37
  }
37
38
 
38
39
  const checkIfSugar = (element, parent, key) => {
39
- const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element
40
+ const {
41
+ extend,
42
+ props,
43
+ childExtend,
44
+ extends: extendProps,
45
+ childrenExtends,
46
+ childProps,
47
+ children,
48
+ on,
49
+ $collection,
50
+ $stateCollection,
51
+ $propsCollection
52
+ } = element
40
53
  const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection
54
+ if (hasComponentAttrs && (childProps || extendProps || children || childrenExtends)) {
55
+ element.error('Sugar component includes params for builtin components')
56
+ }
41
57
  return !hasComponentAttrs || childProps || extendProps || children || childrenExtends
42
58
  }
43
59
 
@@ -58,14 +74,13 @@ export const extendizeByKey = (element, parent, key) => {
58
74
  // console.log(context, context?.components)
59
75
  // console.log(element)
60
76
  const isExtendKeyComponent = context && context.components[extendFromKey]
61
-
62
77
  if (element === isExtendKeyComponent) return element
63
78
  else if (isSugar) {
64
- const newElem = {
79
+ const newElem = addAdditionalExtend(element.extends, {
65
80
  extend: extendFromKey,
66
81
  tag,
67
82
  props: { ...element }
68
- }
83
+ })
69
84
  if (childrenExtends) newElem.childExtend = childrenExtends
70
85
  return newElem
71
86
  } else if (!extend || extend === true) {
@@ -49,6 +49,8 @@ const checkIfKeyIsProperty = (key) => {
49
49
  return /^[a-z]*$/.test(firstCharKey);
50
50
  };
51
51
  const addAdditionalExtend = (newExtend, element) => {
52
+ if (!newExtend)
53
+ return element;
52
54
  const { extend: elementExtend } = element;
53
55
  const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
54
56
  const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
@@ -56,8 +58,23 @@ const addAdditionalExtend = (newExtend, element) => {
56
58
  return { ...element, extend };
57
59
  };
58
60
  const checkIfSugar = (element, parent, key) => {
59
- const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
61
+ const {
62
+ extend,
63
+ props,
64
+ childExtend,
65
+ extends: extendProps,
66
+ childrenExtends,
67
+ childProps,
68
+ children,
69
+ on,
70
+ $collection,
71
+ $stateCollection,
72
+ $propsCollection
73
+ } = element;
60
74
  const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
75
+ if (hasComponentAttrs && (childProps || extendProps || children || childrenExtends)) {
76
+ element.error("Sugar component includes params for builtin components");
77
+ }
61
78
  return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
62
79
  };
63
80
  const extendizeByKey = (element, parent, key) => {
@@ -69,11 +86,11 @@ const extendizeByKey = (element, parent, key) => {
69
86
  if (element === isExtendKeyComponent)
70
87
  return element;
71
88
  else if (isSugar) {
72
- const newElem = {
89
+ const newElem = addAdditionalExtend(element.extends, {
73
90
  extend: extendFromKey,
74
91
  tag,
75
92
  props: { ...element }
76
- };
93
+ });
77
94
  if (childrenExtends)
78
95
  newElem.childExtend = childrenExtends;
79
96
  return newElem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.148",
3
+ "version": "2.5.150",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -25,7 +25,7 @@
25
25
  "build": "yarn build:cjs",
26
26
  "prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
27
27
  },
28
- "gitHead": "6706914c73f3c9669ff443c0c890dea1f4e908ab",
28
+ "gitHead": "8e04bcc422d23520fd394f79be15dc4336cd59a6",
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.12.0"
31
31
  }