Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: web event dataset #1762

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/webpack-plugin/lib/runtime/components/web/event.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { extendEvent } from './getInnerListeners'
import { isBrowser } from '../../env'
import { parseDataset } from '@mpxjs/utils'

function MpxEvent (layer) {
this.targetElement = null
Expand Down Expand Up @@ -64,12 +65,18 @@ function MpxEvent (layer) {
cancelable: true
})
const changedTouches = event.changedTouches || []
extendEvent(event.currentTarget, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个需要在事件handler执行之前进行修改。

dataset: parseDataset(event.currentTarget.dataset)
})
extendEvent(event.target, {
dataset: parseDataset(event.target.dataset)
})
extendEvent(touchEvent, {
timeStamp: event.timeStamp,
changedTouches,
touches: changedTouches,
detail: {
// pc端点击事件可能没有changedTouches,所以直接从 event中取
// pc端点击事件可能没有changedTouches,所以直接从 event 中取
x: changedTouches[0]?.pageX || event.pageX || 0,
y: changedTouches[0]?.pageY || event.pageY || 0
}
Expand Down
Loading