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

getRealEventTarget should use Event.composedPath() instead of Event.path #1239

Open
xiaochengh opened this issue Feb 24, 2022 · 0 comments
Open

Comments

@xiaochengh
Copy link

pickadate.js/lib/picker.js

Lines 996 to 1017 in 0fd34ea

function getRealEventTarget( event, ELEMENT ) {
var path = []
if ( event.path ) {
path = event.path
}
if ( event.originalEvent && event.originalEvent.path ) {
path = event.originalEvent.path
}
if ( path && path.length > 0 ) {
if ( ELEMENT && path.indexOf( ELEMENT ) >= 0 ) {
return ELEMENT
} else {
return path[0]
}
}
return event.target
}

getRealEventTarget() uses Event.path, which is a non-standard API available only in Chromium-based browsers.

It should instead use Event.composedPath() [1], which is a standard API that returns the same result but is supported by all major browsers [2].

Chromium is also deprecating Event.path in favor of Event.composedPath().

See:
[1] https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath
[2] https://caniuse.com/?search=Event.composedPath
[3] https://bugs.chromium.org/p/chromium/issues/detail?id=1277431

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant