@domql/element 2.5.91 → 2.5.94

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.
@@ -53,12 +53,20 @@ const spotByPath = function(path) {
53
53
  }
54
54
  return active;
55
55
  };
56
- const lookup = function(key) {
57
- const element = this;
58
- let { parent } = element;
59
- while (parent.key !== key) {
60
- if (parent[key])
61
- return parent[key];
56
+ const lookup = function(param) {
57
+ const el = this;
58
+ let { parent } = el;
59
+ if ((0, import_utils.isFunction)(param)) {
60
+ if (parent.state && param(parent, parent.state, parent.context))
61
+ return parent;
62
+ else if (parent.parent)
63
+ return parent.lookup(param);
64
+ else
65
+ return;
66
+ }
67
+ while (parent.param !== param) {
68
+ if (parent[param])
69
+ return parent[param];
62
70
  parent = parent.parent;
63
71
  if (!parent)
64
72
  return;
@@ -95,7 +95,7 @@ const createValidDomqlObjectFromSugar = (el, parent, key, options) => {
95
95
  const extendizeByKey = (element, parent, key) => {
96
96
  const { context, tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element;
97
97
  const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data;
98
- const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? key.split("_")[0] : key.includes(".") ? key.split(".")[0] : [key];
98
+ const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? key.split("_")[0] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? key.split(".")[0] : [key];
99
99
  const isExtendKeyComponent = context && context.components[extendFromKey];
100
100
  if (element === isExtendKeyComponent)
101
101
  return element;
@@ -28,13 +28,14 @@ const propagateEventsFromProps = (element) => {
28
28
  eventKeysFromProps.forEach((v) => {
29
29
  const eventName = (0, import_utils.lowercaseFirstLetter)(v.split("on")[1]);
30
30
  const origEvent = on[eventName];
31
+ const funcFromProps = props[v];
31
32
  if ((0, import_utils.isFunction)(origEvent)) {
32
33
  on[eventName] = (...args) => {
33
34
  const originalEventRetunrs = origEvent(...args);
34
35
  if (originalEventRetunrs !== false)
35
- props[v](...args);
36
+ funcFromProps(...args);
36
37
  };
37
38
  } else
38
- on[eventName] = props[v];
39
+ on[eventName] = funcFromProps;
39
40
  });
40
41
  };
package/methods/index.js CHANGED
@@ -23,12 +23,18 @@ export const spotByPath = function (path) {
23
23
  }
24
24
 
25
25
  // TODO: update these files
26
- export const lookup = function (key) {
27
- const element = this
28
- let { parent } = element
26
+ export const lookup = function (param) {
27
+ const el = this
28
+ let { parent } = el
29
+
30
+ if (isFunction(param)) {
31
+ if (parent.state && param(parent, parent.state, parent.context)) return parent
32
+ else if (parent.parent) return parent.lookup(param)
33
+ else return
34
+ }
29
35
 
30
- while (parent.key !== key) {
31
- if (parent[key]) return parent[key]
36
+ while (parent.param !== param) {
37
+ if (parent[param]) return parent[param]
32
38
  parent = parent.parent
33
39
  if (!parent) return
34
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "2.5.91",
3
+ "version": "2.5.94",
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": "15a57f968b6c8832cb843c886e251a89ff17cc24",
34
+ "gitHead": "76edeab829524b706fd1a0bd3fac3fd5563a3b84",
35
35
  "devDependencies": {
36
36
  "@babel/core": "^7.12.0"
37
37
  }
@@ -73,7 +73,7 @@ export const extendizeByKey = (element, parent, key) => {
73
73
  ? key.split('+') // get array of componentKeys
74
74
  : key.includes('_')
75
75
  ? key.split('_')[0] // get component key split _
76
- : key.includes('.')
76
+ : key.includes('.') && !checkIfKeyIsComponent(key.split('.')[1])
77
77
  ? key.split('.')[0] // get component key split .
78
78
  : [key]
79
79
 
@@ -8,11 +8,12 @@ export const propagateEventsFromProps = (element) => {
8
8
  eventKeysFromProps.forEach(v => {
9
9
  const eventName = lowercaseFirstLetter(v.split('on')[1])
10
10
  const origEvent = on[eventName]
11
+ const funcFromProps = props[v]
11
12
  if (isFunction(origEvent)) {
12
13
  on[eventName] = (...args) => {
13
14
  const originalEventRetunrs = origEvent(...args)
14
- if (originalEventRetunrs !== false) props[v](...args)
15
+ if (originalEventRetunrs !== false) funcFromProps(...args)
15
16
  }
16
- } else on[eventName] = props[v]
17
+ } else on[eventName] = funcFromProps
17
18
  })
18
19
  }