@mpxjs/core 2.9.69-beta.8 → 2.9.69-beta.9

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/core",
3
- "version": "2.9.69-beta.8",
3
+ "version": "2.9.69-beta.9",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -26,21 +26,31 @@ export default function getRefsMixin () {
26
26
  })
27
27
  })
28
28
  },
29
- __getRefVal (type, selectorsConf) {
30
- return (instance) => {
31
- if (instance) {
29
+ __getRefVal (type, selectorsConf, refFnId) {
30
+ const target = this
31
+ if (!this[refFnId]) {
32
+ this[refFnId] = function (instance) {
32
33
  selectorsConf.forEach((item = []) => {
33
34
  const [prefix, selectors = ''] = item
34
35
  if (selectors) {
35
36
  selectors.trim().split(/\s+/).forEach(selector => {
36
37
  const refKey = prefix + selector
37
- this.__refs[refKey] = this.__refs[refKey] || []
38
- this.__refs[refKey].push({ type, instance })
38
+ const refVal = { type, instance, refFnId }
39
+ target.__refs[refKey] = target.__refs[refKey] || []
40
+ if (instance) { // mount
41
+ target.__refs[refKey].push(refVal)
42
+ } else { // unmount
43
+ const index = target.__refs[refKey].findIndex(item => item.refFnId === refFnId)
44
+ if (index > -1) {
45
+ target.__refs[refKey].splice(index, 1)
46
+ }
47
+ }
39
48
  })
40
49
  }
41
50
  })
42
51
  }
43
52
  }
53
+ return this[refFnId]
44
54
  },
45
55
  __selectRef (selector, refType, all = false) {
46
56
  const splitedSelector = selector.match(/(#|\.)?[^.#]+/g) || []
@@ -115,7 +115,6 @@ const instanceProto = {
115
115
  return createIntersectionObserver(this, opt, this.__intersectionCtx)
116
116
  },
117
117
  __resetInstance () {
118
- this.__refs = {}
119
118
  this.__dispatchedSlotSet = new WeakSet()
120
119
  },
121
120
  __iter (val, fn) {