@mpxjs/core 2.9.36 → 2.9.38

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.36",
3
+ "version": "2.9.38",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "main": "src/index.js",
21
21
  "dependencies": {
22
- "@mpxjs/utils": "^2.9.1",
22
+ "@mpxjs/utils": "^2.9.38",
23
23
  "lodash": "^4.1.1",
24
24
  "miniprogram-api-typings": "^3.10.0"
25
25
  },
@@ -47,5 +47,5 @@
47
47
  "url": "https://github.com/didi/mpx/issues"
48
48
  },
49
49
  "sideEffects": false,
50
- "gitHead": "23c1e87cde0eafbb4a6526d83551eb5e12740ba8"
50
+ "gitHead": "5e2740e2091edda91eda9ffe775989c7fd9838df"
51
51
  }
@@ -1,21 +1,6 @@
1
- import { setByPath, error, hasOwn, dash2hump } from '@mpxjs/utils'
1
+ import { setByPath, error, dash2hump, collectDataset } from '@mpxjs/utils'
2
2
  import Mpx from '../../index'
3
3
 
4
- const datasetReg = /^data-(.+)$/
5
-
6
- function collectDataset (props) {
7
- const dataset = {}
8
- for (const key in props) {
9
- if (hasOwn(props, key)) {
10
- const matched = datasetReg.exec(key)
11
- if (matched) {
12
- dataset[matched[1]] = props[key]
13
- }
14
- }
15
- }
16
- return dataset
17
- }
18
-
19
4
  export default function proxyEventMixin () {
20
5
  const methods = {
21
6
  __invoke ($event) {
package/src/vuePlugin.js CHANGED
@@ -1,4 +1,4 @@
1
- import { walkChildren, parseSelector, error, hasOwn } from '@mpxjs/utils'
1
+ import { walkChildren, parseSelector, error, hasOwn, collectDataset } from '@mpxjs/utils'
2
2
  import { createSelectorQuery, createIntersectionObserver } from '@mpxjs/api-proxy'
3
3
  import { EffectScope } from 'vue'
4
4
  import { PausedState } from './helper/const'
@@ -55,22 +55,25 @@ const hackEffectScope = () => {
55
55
  }
56
56
  }
57
57
 
58
- const datasetReg = /^data-(.+)$/
59
-
60
- function collectDataset (attrs) {
61
- const dataset = {}
62
- for (const key in attrs) {
63
- if (hasOwn(attrs, key)) {
64
- const matched = datasetReg.exec(key)
65
- if (matched) {
66
- dataset[matched[1]] = attrs[key]
58
+ export default function install (Vue) {
59
+ Object.defineProperties(Vue.prototype, {
60
+ data: {
61
+ get () {
62
+ return Object.assign({}, this.$props, this.$data)
63
+ }
64
+ },
65
+ dataset: {
66
+ get () {
67
+ return collectDataset(this.$attrs, true)
68
+ }
69
+ },
70
+ id: {
71
+ get () {
72
+ return this.$attrs.id || ''
67
73
  }
68
74
  }
69
- }
70
- return dataset
71
- }
75
+ })
72
76
 
73
- export default function install (Vue) {
74
77
  Vue.prototype.triggerEvent = function (eventName, eventDetail) {
75
78
  // 输出Web时自定义组件绑定click事件会和web原生事件冲突,组件内部triggerEvent时会导致事件执行两次,将click事件改为_click来规避此问题
76
79
  const escapeEvents = ['click']
@@ -78,8 +81,8 @@ export default function install (Vue) {
78
81
  eventName = '_' + eventName
79
82
  }
80
83
  let eventObj = {}
81
- const dataset = collectDataset(this.$attrs)
82
- const id = this.$attrs.id || ''
84
+ const dataset = this.dataset
85
+ const id = this.id
83
86
  const timeStamp = +new Date()
84
87
  eventObj = {
85
88
  type: eventName,