@mpxjs/api-proxy 2.7.44 → 2.7.49

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.7.44",
3
+ "version": "2.7.49",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -39,5 +39,5 @@
39
39
  "dependencies": {
40
40
  "axios": "^0.21.1"
41
41
  },
42
- "gitHead": "306aee23bc55c7f1af58b8de0c6e6394370c88d4"
42
+ "gitHead": "d24eb21aeb7b11087d5aaaffb1047e7344bfe9cf"
43
43
  }
@@ -38,29 +38,34 @@ class SelectQuery {
38
38
  const { selector, component, single, fields } = item
39
39
 
40
40
  let curComponent = document
41
-
42
41
  if (component && component.$el) {
43
42
  curComponent = component.$el
44
43
  } else if (component && component.nodeType === 1) {
45
44
  curComponent = component
46
45
  }
47
-
48
- const selectSelf =
49
- curComponent === document
50
- ? false
51
- : Array
52
- .from(curComponent.parentNode.querySelectorAll(selector))
53
- .every(item => item === curComponent)
54
-
55
- if (single) {
56
- const el = selectSelf ? curComponent : curComponent.querySelector(selector)
57
- res.push(handleFields(fields, el, selector))
46
+ if (this._isEl(selector)) {
47
+ if (single) {
48
+ res.push(handleFields(fields, selector, null))
49
+ } else {
50
+ res.push(selector.map(el => handleFields(fields, el, null)))
51
+ }
58
52
  } else {
59
- const els = selectSelf
60
- ? [curComponent]
61
- : curComponent.querySelectorAll(selector)
62
- const elsArr = Array.from(els).map(el => handleFields(fields, el, null))
63
- res.push(elsArr)
53
+ const selectSelf =
54
+ curComponent === document
55
+ ? false
56
+ : Array
57
+ .from(curComponent.parentNode.querySelectorAll(selector))
58
+ .every(item => item === curComponent)
59
+ if (single) {
60
+ const el = selectSelf ? curComponent : curComponent.querySelector(selector)
61
+ res.push(handleFields(fields, el, selector))
62
+ } else {
63
+ const els = selectSelf
64
+ ? [curComponent]
65
+ : curComponent.querySelectorAll(selector)
66
+ const elsArr = Array.from(els).map(el => handleFields(fields, el, null))
67
+ res.push(elsArr)
68
+ }
64
69
  }
65
70
  })
66
71
  res.forEach((item, idx) => {
@@ -162,6 +167,10 @@ class SelectQuery {
162
167
  })
163
168
  this._queueCb.push(callback)
164
169
  }
170
+ _isEl (selector) {
171
+ if (Array.isArray(selector)) return this._isEl(selector[0])
172
+ return selector && selector.nodeType === 1
173
+ }
165
174
  }
166
175
 
167
176
  export default SelectQuery