@domql/element 2.5.88 → 2.5.93

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,19 +53,27 @@ 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;
65
73
  }
66
74
  return parent;
67
75
  };
68
- const remove = function(params) {
76
+ const remove = function() {
69
77
  const element = this;
70
78
  if ((0, import_utils.isFunction)(element.node.remove))
71
79
  element.node.remove();
@@ -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
  }
@@ -36,7 +42,7 @@ export const lookup = function (key) {
36
42
  return parent
37
43
  }
38
44
 
39
- export const remove = function (params) {
45
+ export const remove = function () {
40
46
  const element = this
41
47
  if (isFunction(element.node.remove)) element.node.remove()
42
48
  else if (!isProduction()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "2.5.88",
3
+ "version": "2.5.93",
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": "e22cca853bb518bc4e3422e3af0b92d52b82639e",
34
+ "gitHead": "6c5a9e10c74137700ad69ff9108b6ccc09745cc7",
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('.') // TODO: add only Component.camelCase cases - avoud Component.Variant
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
  }