Skip to content

Commit

Permalink
fix(taro-tt): 兼容头条小程序事件处理
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed Dec 7, 2018
1 parent a474c6f commit 56ac2a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/taro-tt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup -c rollup.config.js"
"build": "rollup -c rollup.config.js",
"watch": "rollup -c rollup.config.js -w"
},
"repository": {
"type": "git",
Expand Down
12 changes: 10 additions & 2 deletions packages/taro-tt/src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,18 @@ class BaseComponent {
} else {
// 普通的
const keyLower = key.toLocaleLowerCase()
this.$scope.triggerEvent(keyLower, {

const payload = {
__isCustomEvt: true,
__arguments: args
})
}

const detail = this.$scope.dataset
if (Object.keys(detail).length) {
payload.__detail = detail
}

this.$scope.triggerEvent(keyLower, payload)
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/taro-tt/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ function processEvent (eventHandlerName, obj) {
const dataset = event.currentTarget.dataset || {}
const bindArgs = {}
const eventHandlerNameLower = eventHandlerName.toLocaleLowerCase()

if (event.detail && event.detail.__detail) Object.assign(dataset, event.detail.__detail)

Object.keys(dataset).forEach(key => {
let keyLower = key.toLocaleLowerCase()
if (/^e/.test(keyLower)) {
Expand Down

0 comments on commit 56ac2a2

Please sign in to comment.