@domql/element 2.5.149 → 2.5.151

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
@@ -90,7 +90,7 @@ const create = (element, parent, key, options = OPTIONS.create || {}, attachOpti
90
90
  createIfConditionFlag(element, parent)
91
91
 
92
92
  // apply props settings
93
- createProps(element, parent)
93
+ createProps(element, parent, options)
94
94
  if (element.scope === 'props' || element.scope === true) element.scope = element.props
95
95
 
96
96
  // recatch if it passess props again
@@ -234,7 +234,7 @@ const renderElement = (element, parent, options, attachOptions) => {
234
234
  const isDemoComponent = element.lookup(el => el.state.key)?.state?.key
235
235
  element.warn('Error happened in:', isDemoComponent ? isDemoComponent + ' ' : '' + path.join('.'))
236
236
  element.verbose()
237
- element.error(e)
237
+ element.error(e, options)
238
238
  if (element.on?.error) element.on.error(e, element, element.state, element.context, options)
239
239
  if (element.props?.onError) element.props.onError(e, element, element.state, element.context, options)
240
240
  }
@@ -354,7 +354,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
354
354
  createIfConditionFlag(element, parent)
355
355
 
356
356
  // apply props settings
357
- createProps(element, parent)
357
+ createProps(element, parent, options)
358
358
  if (element.scope === 'props' || element.scope === true) element.scope = element.props
359
359
 
360
360
  if (element.node && ref.__if) { parent[key || element.key] = element } // Borrowed from assignNode()
@@ -74,7 +74,7 @@ const create = (element, parent, key, options = import_options.default.create ||
74
74
  if (element.scope === "state")
75
75
  element.scope = element.state;
76
76
  createIfConditionFlag(element, parent);
77
- (0, import_props.createProps)(element, parent);
77
+ (0, import_props.createProps)(element, parent, options);
78
78
  if (element.scope === "props" || element.scope === true)
79
79
  element.scope = element.props;
80
80
  createIfConditionFlag(element, parent);
@@ -192,7 +192,7 @@ const renderElement = (element, parent, options, attachOptions) => {
192
192
  const isDemoComponent = (_b = (_a = element.lookup((el) => el.state.key)) == null ? void 0 : _a.state) == null ? void 0 : _b.key;
193
193
  element.warn("Error happened in:", isDemoComponent ? isDemoComponent + " " : "" + path.join("."));
194
194
  element.verbose();
195
- element.error(e);
195
+ element.error(e, options);
196
196
  if ((_c = element.on) == null ? void 0 : _c.error)
197
197
  element.on.error(e, element, element.state, element.context, options);
198
198
  if ((_d = element.props) == null ? void 0 : _d.onError)
@@ -283,7 +283,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
283
283
  if (element.scope === "state")
284
284
  element.scope = element.state;
285
285
  createIfConditionFlag(element, parent);
286
- (0, import_props.createProps)(element, parent);
286
+ (0, import_props.createProps)(element, parent, options);
287
287
  if (element.scope === "props" || element.scope === true)
288
288
  element.scope = element.props;
289
289
  if (element.node && ref.__if) {
@@ -166,7 +166,7 @@ function keys() {
166
166
  const element = this;
167
167
  const keys2 = [];
168
168
  for (const param in element) {
169
- if (import_mixins.registry[param] && !import_mixins.parseFilters.elementKeys.includes(param)) {
169
+ if (import_mixins.registry[param] && !import_mixins.parseFilters.elementKeys.includes(param) || Object.hasOwnProperty.call(element, param)) {
170
170
  continue;
171
171
  }
172
172
  keys2.push(param);
@@ -178,7 +178,6 @@ function parse(excl = []) {
178
178
  const obj = {};
179
179
  const keyList = keys.call(element);
180
180
  keyList.forEach((v) => {
181
- var _a;
182
181
  if (excl.includes(v))
183
182
  return;
184
183
  const val = element[v];
@@ -194,7 +193,7 @@ function parse(excl = []) {
194
193
  } else if (v === "props") {
195
194
  const { __element, update, ...props } = element[v];
196
195
  obj[v] = props;
197
- } else if ((0, import_utils.isDefined)(val) && !((_a = element.context) == null ? void 0 : _a.methods[v]))
196
+ } else if ((0, import_utils.isDefined)(val) && Object.hasOwnProperty.call(element, v))
198
197
  obj[v] = val;
199
198
  });
200
199
  return obj;
@@ -216,7 +215,7 @@ function verbose(...args) {
216
215
  return;
217
216
  const element = this;
218
217
  const { __ref: ref } = element;
219
- console.group(element.key);
218
+ console.groupCollapsed(element.key);
220
219
  if (args.length) {
221
220
  args.forEach((v) => console.log(`%c${v}:
222
221
  `, "font-weight: bold", element[v]));
@@ -240,8 +239,13 @@ function warn(...params) {
240
239
  }
241
240
  }
242
241
  function error(...params) {
242
+ var _a, _b;
243
243
  if (ENV === "test" || ENV === "development") {
244
+ if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger)
245
+ debugger;
244
246
  console.error(...params);
247
+ if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose)
248
+ this.verbose();
245
249
  }
246
250
  }
247
251
  function nextElement() {
@@ -25,8 +25,8 @@ var import_utils = require("@domql/utils");
25
25
  var import_report = require("@domql/report");
26
26
  var data_default = (params, element, node) => {
27
27
  if (params) {
28
- if (element.props.attr)
29
- (0, import_utils.deepMerge)(params, element.props.attr);
28
+ if (element.props.data)
29
+ (0, import_utils.deepMerge)(params, element.props.data);
30
30
  if (params.showOnNode) {
31
31
  if (!(0, import_utils.isObject)(params))
32
32
  (0, import_report.report)("HTMLInvalidData", params);
@@ -43,13 +43,18 @@ const createPropsStack = (element, parent) => {
43
43
  ref.__props = propsStack;
44
44
  return propsStack;
45
45
  };
46
- const syncProps = (props, element) => {
46
+ const syncProps = (props, element, opts) => {
47
47
  element.props = {};
48
48
  const mergedProps = {};
49
49
  props.forEach((v) => {
50
50
  if (import_ignore.IGNORE_PROPS_PARAMS.includes(v))
51
51
  return;
52
- const execProps = (0, import_utils.exec)(v, element);
52
+ let execProps;
53
+ try {
54
+ execProps = (0, import_utils.exec)(v, element);
55
+ } catch (e) {
56
+ element.error(e, opts);
57
+ }
53
58
  element.props = (0, import_utils.deepMerge)(
54
59
  mergedProps,
55
60
  (0, import_utils.deepCloneWithExtend)(execProps, import_ignore.IGNORE_PROPS_PARAMS),
@@ -61,15 +66,15 @@ const syncProps = (props, element) => {
61
66
  Object.setPrototypeOf(element.props, methods);
62
67
  return element.props;
63
68
  };
64
- const createProps = function(element, parent, cached) {
69
+ const createProps = function(element, parent, options) {
65
70
  const { __ref: ref } = element;
66
71
  const applyProps = () => {
67
- const propsStack = cached || createPropsStack(element, parent);
72
+ const propsStack = options.cachedProps || createPropsStack(element, parent);
68
73
  if (propsStack.length) {
69
74
  ref.__props = propsStack;
70
75
  syncProps(propsStack, element);
71
76
  } else {
72
- ref.__props = cached || [];
77
+ ref.__props = options.cachedProps || [];
73
78
  element.props = {};
74
79
  }
75
80
  };
@@ -80,7 +85,7 @@ const createProps = function(element, parent, cached) {
80
85
  applyProps();
81
86
  } catch {
82
87
  element.props = {};
83
- ref.__props = cached || [];
88
+ ref.__props = options.cachedProps || [];
84
89
  }
85
90
  }
86
91
  const methods = { update: update.bind(element.props), __element: element };
@@ -69,7 +69,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
69
69
  if (element.node && ref.__if) {
70
70
  parent[key || element.key] = element;
71
71
  }
72
- (0, import_props.createProps)(element, parent);
72
+ (0, import_props.createProps)(element, parent, options);
73
73
  (0, import__2.applyVariant)(element, parent);
74
74
  if (element.tag !== "string" && element.tag !== "fragment") {
75
75
  (0, import_iterate.throughInitialDefine)(element);
package/methods/index.js CHANGED
@@ -136,7 +136,7 @@ export function keys () {
136
136
  const element = this
137
137
  const keys = []
138
138
  for (const param in element) {
139
- if (registry[param] && !parseFilters.elementKeys.includes(param)) { continue }
139
+ if ((registry[param] && !parseFilters.elementKeys.includes(param)) || Object.hasOwnProperty.call(element, param)) { continue }
140
140
  keys.push(param)
141
141
  }
142
142
  return keys
@@ -159,7 +159,7 @@ export function parse (excl = []) {
159
159
  } else if (v === 'props') {
160
160
  const { __element, update, ...props } = element[v]
161
161
  obj[v] = props
162
- } else if (isDefined(val) && !element.context?.methods[v]) obj[v] = val
162
+ } else if (isDefined(val) && Object.hasOwnProperty.call(element, v)) obj[v] = val
163
163
  })
164
164
  return obj
165
165
  }
@@ -179,7 +179,7 @@ export function verbose (...args) {
179
179
 
180
180
  const element = this
181
181
  const { __ref: ref } = element
182
- console.group(element.key)
182
+ console.groupCollapsed(element.key)
183
183
  if (args.length) {
184
184
  args.forEach(v => console.log(`%c${v}:\n`, 'font-weight: bold', element[v]))
185
185
  } else {
@@ -205,7 +205,9 @@ export function warn (...params) {
205
205
 
206
206
  export function error (...params) {
207
207
  if (ENV === 'test' || ENV === 'development') {
208
+ if (params[params.length - 1]?.debugger) debugger // eslint-disable-line
208
209
  console.error(...params)
210
+ if (params[params.length - 1]?.verbose) this.verbose()
209
211
  }
210
212
  }
211
213
 
package/mixins/data.js CHANGED
@@ -9,7 +9,7 @@ import { report } from '@domql/report'
9
9
  */
10
10
  export default (params, element, node) => {
11
11
  if (params) {
12
- if (element.props.attr) deepMerge(params, element.props.attr)
12
+ if (element.props.data) deepMerge(params, element.props.data)
13
13
  if (params.showOnNode) {
14
14
  if (!isObject(params)) report('HTMLInvalidData', params)
15
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "2.5.149",
3
+ "version": "2.5.151",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -26,12 +26,12 @@
26
26
  "prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
27
27
  },
28
28
  "dependencies": {
29
- "@domql/event": "^2.5.148",
30
- "@domql/render": "^2.5.148",
31
- "@domql/state": "^2.5.148",
32
- "@domql/utils": "^2.5.148"
29
+ "@domql/event": "^2.5.151",
30
+ "@domql/render": "^2.5.151",
31
+ "@domql/state": "^2.5.151",
32
+ "@domql/utils": "^2.5.151"
33
33
  },
34
- "gitHead": "0fc54dc04c46c99dc37afab72464ac0457fcea73",
34
+ "gitHead": "f37b51f84b8bca80b8bce7887e83d61ac25eb3d5",
35
35
  "devDependencies": {
36
36
  "@babel/core": "^7.12.0"
37
37
  }
package/props/create.js CHANGED
@@ -24,13 +24,16 @@ const createPropsStack = (element, parent) => {
24
24
  return propsStack
25
25
  }
26
26
 
27
- export const syncProps = (props, element) => {
27
+ export const syncProps = (props, element, opts) => {
28
28
  element.props = {}
29
29
  const mergedProps = {}
30
30
 
31
31
  props.forEach(v => {
32
32
  if (IGNORE_PROPS_PARAMS.includes(v)) return
33
- const execProps = exec(v, element)
33
+ let execProps
34
+ try {
35
+ execProps = exec(v, element)
36
+ } catch (e) { element.error(e, opts) }
34
37
  // TODO: check if this failing the function props merge
35
38
  // if (isObject(execProps) && execProps.__element) return
36
39
  // it was causing infinite loop at early days
@@ -48,16 +51,16 @@ export const syncProps = (props, element) => {
48
51
  return element.props
49
52
  }
50
53
 
51
- export const createProps = function (element, parent, cached) {
54
+ export const createProps = function (element, parent, options) {
52
55
  const { __ref: ref } = element
53
56
 
54
57
  const applyProps = () => {
55
- const propsStack = cached || createPropsStack(element, parent)
58
+ const propsStack = options.cachedProps || createPropsStack(element, parent)
56
59
  if (propsStack.length) {
57
60
  ref.__props = propsStack
58
61
  syncProps(propsStack, element)
59
62
  } else {
60
- ref.__props = cached || []
63
+ ref.__props = options.cachedProps || []
61
64
  element.props = {}
62
65
  }
63
66
  }
@@ -68,7 +71,7 @@ export const createProps = function (element, parent, cached) {
68
71
  applyProps()
69
72
  } catch {
70
73
  element.props = {}
71
- ref.__props = cached || []
74
+ ref.__props = options.cachedProps || []
72
75
  }
73
76
  }
74
77
 
@@ -70,7 +70,7 @@ export const onlyResolveExtends = (element, parent, key, options) => {
70
70
 
71
71
  if (element.node && ref.__if) { parent[key || element.key] = element } // Borrowed from assignNode()
72
72
 
73
- createProps(element, parent)
73
+ createProps(element, parent, options)
74
74
  applyVariant(element, parent)
75
75
 
76
76
  if (element.tag !== 'string' && element.tag !== 'fragment') {