@domql/utils 2.5.139 → 2.5.141

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
@@ -6,6 +6,7 @@ import {
6
6
  isArray,
7
7
  isFunction,
8
8
  isObject,
9
+ isObjectLike,
9
10
  isString,
10
11
  joinArrays,
11
12
  overwriteDeep
@@ -96,11 +97,20 @@ export const addChildrenIfNotInOriginal = (element, parent, key) => {
96
97
  const childKey = childElems[i]
97
98
  const childElem = element[childKey]
98
99
  const newChild = element.props[childKey]
99
- if (newChild.ignoreExtend) continue
100
+ if (newChild?.ignoreExtend) continue
100
101
  if (!childElem) element[childKey] = deepCloneWithExtend(newChild)
101
102
  else {
102
103
  const isSugar = checkIfSugar(childElem)
103
- if (!isSugar) overwriteDeep(element[childKey].props, newChild)
104
+ if (!isSugar) continue
105
+ const inheritedChildElem = element[childKey].props
106
+ if (isObjectLike(newChild)) {
107
+ overwriteDeep(inheritedChildElem, newChild)
108
+ } else if (isFunction(newChild)) {
109
+ element[childKey] = {
110
+ extend: element[childKey],
111
+ props: newChild
112
+ }
113
+ }
104
114
  }
105
115
  }
106
116
  }
@@ -195,3 +205,13 @@ export const getExtendsInElement = (obj) => {
195
205
  traverse(obj)
196
206
  return result
197
207
  }
208
+
209
+ export const setContentKey = (el, opts = {}) => {
210
+ const { __ref: ref } = el
211
+ const contentElementKey = opts.contentElementKey
212
+ if ((contentElementKey !== 'content' && contentElementKey !== ref.contentElementKey) || !ref.contentElementKey) {
213
+ ref.contentElementKey = contentElementKey || 'content'
214
+ } else ref.contentElementKey = 'content'
215
+ if (contentElementKey !== 'content') opts.contentElementKey = 'content'
216
+ return ref.contentElementKey
217
+ }
@@ -28,7 +28,8 @@ __export(component_exports, {
28
28
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
29
29
  getExtendsInElement: () => getExtendsInElement,
30
30
  hasVariantProp: () => hasVariantProp,
31
- isVariant: () => isVariant
31
+ isVariant: () => isVariant,
32
+ setContentKey: () => setContentKey
32
33
  });
33
34
  module.exports = __toCommonJS(component_exports);
34
35
  var import__ = require(".");
@@ -103,14 +104,23 @@ const addChildrenIfNotInOriginal = (element, parent, key) => {
103
104
  const childKey = childElems[i];
104
105
  const childElem = element[childKey];
105
106
  const newChild = element.props[childKey];
106
- if (newChild.ignoreExtend)
107
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
107
108
  continue;
108
109
  if (!childElem)
109
110
  element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
110
111
  else {
111
112
  const isSugar = checkIfSugar(childElem);
112
113
  if (!isSugar)
113
- (0, import__.overwriteDeep)(element[childKey].props, newChild);
114
+ continue;
115
+ const inheritedChildElem = element[childKey].props;
116
+ if ((0, import__.isObjectLike)(newChild)) {
117
+ (0, import__.overwriteDeep)(inheritedChildElem, newChild);
118
+ } else if ((0, import__.isFunction)(newChild)) {
119
+ element[childKey] = {
120
+ extend: element[childKey],
121
+ props: newChild
122
+ };
123
+ }
114
124
  }
115
125
  }
116
126
  };
@@ -189,3 +199,14 @@ const getExtendsInElement = (obj) => {
189
199
  traverse(obj);
190
200
  return result;
191
201
  };
202
+ const setContentKey = (el, opts = {}) => {
203
+ const { __ref: ref } = el;
204
+ const contentElementKey = opts.contentElementKey;
205
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
206
+ ref.contentElementKey = contentElementKey || "content";
207
+ } else
208
+ ref.contentElementKey = "content";
209
+ if (contentElementKey !== "content")
210
+ opts.contentElementKey = "content";
211
+ return ref.contentElementKey;
212
+ };
package/dist/cjs/tags.js CHANGED
@@ -31,10 +31,13 @@ const HTML_TAGS = {
31
31
  "title",
32
32
  "base",
33
33
  "meta",
34
- "style"
34
+ "style",
35
+ "noscript",
36
+ "script"
35
37
  ],
36
38
  body: [
37
39
  "string",
40
+ "style",
38
41
  "fragment",
39
42
  "a",
40
43
  "abbr",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.139",
3
+ "version": "2.5.141",
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": "db49c6131a93bd7e9c1f1c95bc5de7752a8f48d1",
28
+ "gitHead": "c77d004ddb710821445be4dce056410b004f13ea",
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.12.0"
31
31
  }
package/tags.js CHANGED
@@ -10,11 +10,14 @@ export const HTML_TAGS = {
10
10
  'title',
11
11
  'base',
12
12
  'meta',
13
- 'style'
13
+ 'style',
14
+ 'noscript',
15
+ 'script'
14
16
  ],
15
17
 
16
18
  body: [
17
19
  'string',
20
+ 'style',
18
21
  'fragment',
19
22
  'a',
20
23
  'abbr',