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 interoperability issue regarding Event properties #36235

Closed
wants to merge 2 commits into from
Closed
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
19 changes: 12 additions & 7 deletions js/src/dom/event-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function getEvent(element) {

function bootstrapHandler(element, fn) {
return function handler(event) {
event.delegateTarget = element
setEventProperty(event, 'delegateTarget', element)

if (handler.oneOff) {
EventHandler.off(element, event.type, fn)
Expand All @@ -109,7 +109,7 @@ function bootstrapDelegationHandler(element, selector, fn) {
continue
}

event.delegateTarget = target
setEventProperty(event, 'delegateTarget', target)

if (handler.oneOff) {
EventHandler.off(element, event.type, selector, fn)
Expand Down Expand Up @@ -219,6 +219,15 @@ function getTypeEvent(event) {
return customEvents[event] || event
}

function setEventProperty(event, propName, value) {
Object.defineProperty(event, propName, {
configurable: true,
get() {
return value
}
})
}

const EventHandler = {
on(element, event, handler, delegationFunction) {
addHandler(element, event, handler, delegationFunction, false)
Expand Down Expand Up @@ -293,11 +302,7 @@ const EventHandler = {
// merge custom information in our event
if (typeof args !== 'undefined') {
for (const key of Object.keys(args)) {
Object.defineProperty(evt, key, {
get() {
return args[key]
}
})
setEventProperty(evt, key, args[key])
}
}

Expand Down