@mpxjs/core 2.9.1 → 2.9.5

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.1",
3
+ "version": "2.9.5",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -47,5 +47,5 @@
47
47
  "url": "https://github.com/didi/mpx/issues"
48
48
  },
49
49
  "sideEffects": false,
50
- "gitHead": "5460efb7afae97e321ff608258a8c0ad0b366f4c"
50
+ "gitHead": "beefb0935f3aa9d3605dd6f31b8cd37094186488"
51
51
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ BEFORECREATE,
2
3
  CREATED,
3
4
  ONHIDE,
4
5
  ONSHOW,
@@ -47,6 +48,18 @@ if (isBrowser) {
47
48
  window.addEventListener('resize', onResize)
48
49
  }
49
50
 
51
+ function getParentPage (vm) {
52
+ let parent = vm.$parent
53
+ while (parent) {
54
+ if (parent.route) {
55
+ return parent
56
+ } else if (parent.$page) {
57
+ return parent.$page
58
+ }
59
+ parent = parent.$parent
60
+ }
61
+ }
62
+
50
63
  export default function pageStatusMixin (mixinType) {
51
64
  const mixin = {}
52
65
 
@@ -69,10 +82,19 @@ export default function pageStatusMixin (mixinType) {
69
82
  })
70
83
  }
71
84
 
85
+ // 创建组件时记录当前所属page,用于驱动pageLifetimes和onShow/onHide钩子
86
+ if (mixinType === 'component') {
87
+ Object.assign(mixin, {
88
+ [BEFORECREATE] () {
89
+ this.$page = getParentPage(this)
90
+ }
91
+ })
92
+ }
93
+
72
94
  Object.assign(mixin, {
73
95
  [CREATED] () {
74
96
  if (isBrowser) {
75
- const pageInstance = mixinType === 'page' ? this : getCurrentPageInstance()
97
+ const pageInstance = mixinType === 'page' ? this : this.$page
76
98
  if (pageInstance) {
77
99
  this.$watch(() => pageInstance.mpxPageStatus, status => {
78
100
  if (!status) return
@@ -35,7 +35,7 @@ export default function proxyEventMixin () {
35
35
  let fallbackType = ''
36
36
  if (type === 'begin' || type === 'end') {
37
37
  // 地图的 regionchange 事件会派发 e.type 为 begin 和 end 的事件
38
- fallbackType = 'regionchange'
38
+ fallbackType = __mpx_mode__ === 'ali' ? 'regionChange' : 'regionchange'
39
39
  } else if (/-([a-z])/.test(type)) {
40
40
  fallbackType = dash2hump(type)
41
41
  } else if (__mpx_mode__ === 'ali') {