Skip to content

Commit

Permalink
feat: 😾eventTarget srcElement fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jardenliu committed Aug 15, 2023
1 parent 5be0171 commit 6b609ae
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions packages/core/src/plugins/event/eventTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,26 @@ const patchEventTarget = () => {
return path[0]
}

Object.defineProperty(Event.prototype, 'target', {
get () {
function targetGet () {
// @ts-ignore
const that = this
if (that.composed && that.composedPath() && that.composedPath()[0]) {
return getTargetFormPath(that.composedPath(), that.type)
}

if (this.composed && this.composedPath() && this.composedPath()[0]) {
return getTargetFormPath(this.composedPath(), this.type)
}
if (that.path && that.path[0]) {
return getTargetFormPath(that.path, that.type)
}

if (this.path && this.path[0]) {
return getTargetFormPath(this.path, this.type)
}
return that.__WUJIE_POLYFILL_TARGET__
}

Object.defineProperty(Event.prototype, 'target', {
get: targetGet,
})

return this.__WUJIE_POLYFILL_TARGET__
},
Object.defineProperty(Event.prototype, 'srcElement', {
get: targetGet,
})

}
Expand Down

0 comments on commit 6b609ae

Please sign in to comment.