@domql/element 2.5.116 → 2.5.118

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.
@@ -28,7 +28,8 @@ let mainExtend;
28
28
  const applyExtend = (element, parent, options = {}) => {
29
29
  if ((0, import_utils.isFunction)(element))
30
30
  element = (0, import_utils.exec)(element, parent);
31
- let { extend, props, __ref } = element;
31
+ const { props, __ref } = element;
32
+ let extend = (props == null ? void 0 : props.extends) || element.extend;
32
33
  const context = element.context || parent.context;
33
34
  extend = (0, import_utils2.fallbackStringExtend)(extend, context, options);
34
35
  const extendStack = (0, import_utils2.getExtendStack)(extend, context);
@@ -33,20 +33,8 @@ __export(component_exports, {
33
33
  module.exports = __toCommonJS(component_exports);
34
34
  var import_utils = require("@domql/utils");
35
35
  var import_extend = require("../extend");
36
+ var import_mixins = require("../mixins");
36
37
  const ENV = "development";
37
- const DOMQL_BUILTINS = [
38
- "extend",
39
- "childExtend",
40
- "childExtendRecursive",
41
- "define",
42
- "props",
43
- "state",
44
- "on",
45
- "if",
46
- "attr",
47
- "key",
48
- "tag"
49
- ];
50
38
  const checkIfKeyIsComponent = (key) => {
51
39
  const isFirstKeyString = (0, import_utils.isString)(key);
52
40
  if (!isFirstKeyString)
@@ -77,17 +65,16 @@ const createValidDomqlObjectFromSugar = (el, parent, key, options) => {
77
65
  for (const k in el) {
78
66
  const prop = el[k];
79
67
  const isEvent = k.startsWith("on");
80
- const isMethod = k.startsWith("$");
81
68
  if (isEvent) {
82
69
  const onKey = replaceOnKeys(prop);
83
70
  newElem.on[onKey] = prop;
84
- } else if (!isMethod && checkIfKeyIsProperty(k)) {
85
- if (!DOMQL_BUILTINS.includes(k))
86
- newElem.props[k] = prop;
87
- } else if (checkIfKeyIsComponent(k)) {
71
+ }
72
+ const isComponent = checkIfKeyIsComponent(k);
73
+ const isRegistry = import_mixins.registry[k];
74
+ if (isComponent || isRegistry) {
88
75
  newElem[k] = prop;
89
76
  } else {
90
- newElem[k] = prop;
77
+ newElem.props[k] = prop;
91
78
  }
92
79
  }
93
80
  return newElem;
@@ -64,19 +64,28 @@ const clone = (obj, exclude = METHODS_EXL) => {
64
64
  }
65
65
  return o;
66
66
  };
67
- const deepClone = (obj, exclude = METHODS_EXL) => {
68
- const o = (0, import_utils.isArray)(obj) ? [] : {};
69
- for (const e in obj) {
70
- if (exclude.includes(e))
71
- continue;
72
- let objProp = obj[e];
73
- if (e === "extend" && (0, import_utils.isArray)(objProp)) {
74
- objProp = mergeArray(objProp, exclude);
67
+ const deepClone = (obj, exclude = METHODS_EXL, seen = /* @__PURE__ */ new WeakMap()) => {
68
+ if (obj === null || typeof obj !== "object") {
69
+ return obj;
70
+ }
71
+ if (obj instanceof window.Node || obj === window || obj instanceof window.Document) {
72
+ return obj;
73
+ }
74
+ if (seen.has(obj)) {
75
+ return seen.get(obj);
76
+ }
77
+ const o = Array.isArray(obj) ? [] : {};
78
+ seen.set(obj, o);
79
+ for (const key in obj) {
80
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
81
+ if (exclude.includes(key))
82
+ continue;
83
+ let value = obj[key];
84
+ if (key === "extend" && Array.isArray(value)) {
85
+ value = mergeArray(value, exclude);
86
+ }
87
+ o[key] = deepClone(value, exclude, seen);
75
88
  }
76
- if ((0, import_utils.isObjectLike)(objProp)) {
77
- o[e] = deepClone(objProp, exclude);
78
- } else
79
- o[e] = objProp;
80
89
  }
81
90
  return o;
82
91
  };
package/extend.js CHANGED
@@ -20,7 +20,8 @@ let mainExtend
20
20
  export const applyExtend = (element, parent, options = {}) => {
21
21
  if (isFunction(element)) element = exec(element, parent)
22
22
 
23
- let { extend, props, __ref } = element
23
+ const { props, __ref } = element
24
+ let extend = props?.extends || element.extend
24
25
  const context = element.context || parent.context
25
26
 
26
27
  extend = fallbackStringExtend(extend, context, options)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "2.5.116",
3
+ "version": "2.5.118",
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": "cff7d465161d804f31e3b350081bb751da209eeb",
34
+ "gitHead": "984906ba70b23710f6f1a1895b41b4e8710e4c3d",
35
35
  "devDependencies": {
36
36
  "@babel/core": "^7.12.0"
37
37
  }
@@ -2,22 +2,9 @@
2
2
 
3
3
  import { exec, isArray, isFunction, isObject, isString, joinArrays, overwriteDeep } from '@domql/utils'
4
4
  import { applyExtend } from '../extend'
5
+ import { registry } from '../mixins'
5
6
  const ENV = process.env.NODE_ENV
6
7
 
7
- const DOMQL_BUILTINS = [
8
- 'extend',
9
- 'childExtend',
10
- 'childExtendRecursive',
11
- 'define',
12
- 'props',
13
- 'state',
14
- 'on',
15
- 'if',
16
- 'attr',
17
- 'key',
18
- 'tag'
19
- ]
20
-
21
8
  export const checkIfKeyIsComponent = (key) => {
22
9
  const isFirstKeyString = isString(key)
23
10
  if (!isFirstKeyString) return
@@ -50,16 +37,18 @@ export const createValidDomqlObjectFromSugar = (el, parent, key, options) => {
50
37
  for (const k in el) {
51
38
  const prop = el[k]
52
39
  const isEvent = k.startsWith('on')
53
- const isMethod = k.startsWith('$')
54
40
  if (isEvent) {
55
41
  const onKey = replaceOnKeys(prop)
56
42
  newElem.on[onKey] = prop
57
- } else if (!isMethod && checkIfKeyIsProperty(k)) {
58
- if (!DOMQL_BUILTINS.includes(k)) newElem.props[k] = prop
59
- } else if (checkIfKeyIsComponent(k)) {
43
+ // } else if (!isMethod && checkIfKeyIsProperty(k)) {
44
+ }
45
+
46
+ const isComponent = checkIfKeyIsComponent(k)
47
+ const isRegistry = registry[k]
48
+ if (isComponent || isRegistry) {
60
49
  newElem[k] = prop
61
50
  } else {
62
- newElem[k] = prop
51
+ newElem.props[k] = prop
63
52
  }
64
53
  }
65
54
  return newElem
package/utils/object.js CHANGED
@@ -38,21 +38,60 @@ export const clone = (obj, exclude = METHODS_EXL) => {
38
38
  /**
39
39
  * Deep cloning of object
40
40
  */
41
- export const deepClone = (obj, exclude = METHODS_EXL) => {
42
- const o = isArray(obj) ? [] : {}
43
- for (const e in obj) {
44
- if (exclude.includes(e)) continue
45
- let objProp = obj[e]
46
- if (e === 'extend' && isArray(objProp)) {
47
- objProp = mergeArray(objProp, exclude)
41
+ export const deepClone = (obj, exclude = METHODS_EXL, seen = new WeakMap()) => {
42
+ // Check for null or undefined
43
+ if (obj === null || typeof obj !== 'object') {
44
+ return obj
45
+ }
46
+
47
+ // Check for DOM nodes, Window, or Document
48
+ if (obj instanceof window.Node || obj === window || obj instanceof window.Document) {
49
+ return obj
50
+ }
51
+
52
+ // Check for circular references
53
+ if (seen.has(obj)) {
54
+ return seen.get(obj)
55
+ }
56
+
57
+ // Create a new object or array
58
+ const o = Array.isArray(obj) ? [] : {}
59
+
60
+ // Store this object in our circular reference map
61
+ seen.set(obj, o)
62
+
63
+ for (const key in obj) {
64
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
65
+ if (exclude.includes(key)) continue
66
+
67
+ let value = obj[key]
68
+
69
+ if (key === 'extend' && Array.isArray(value)) {
70
+ value = mergeArray(value, exclude)
71
+ }
72
+
73
+ o[key] = deepClone(value, exclude, seen)
48
74
  }
49
- if (isObjectLike(objProp)) {
50
- o[e] = deepClone(objProp, exclude)
51
- } else o[e] = objProp
52
75
  }
76
+
53
77
  return o
54
78
  }
55
79
 
80
+ // export const deepClone = (obj, exclude = METHODS_EXL) => {
81
+ // const o = isArray(obj) ? [] : {}
82
+ // for (const e in obj) {
83
+ // if (exclude.includes(e)) continue
84
+ // let objProp = obj[e]
85
+ // if (e === 'extend' && isArray(objProp)) {
86
+ // objProp = mergeArray(objProp, exclude)
87
+ // }
88
+ // if (isObjectLike(objProp)) {
89
+ // o[e] = deepClone(objProp, exclude)
90
+ // } else o[e] = objProp
91
+ // }
92
+ // return o
93
+ // }
94
+
56
95
  /**
57
96
  * Overwrites object properties with another
58
97
  */