mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-09-23 18:29:35 +00:00
Account for syntax errors in closest selector
Certain browsers have the closest method but do not support not selectors with multiple arguments. This variant caters for both. Bug: T325113 Change-Id: Ib5fc912bfe0f831fea4c9882c25b27541d83b66f
This commit is contained in:
parent
01e3ddcda5
commit
7295ee3a6a
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map.json
vendored
BIN
resources/dist/index.js.map.json
vendored
Binary file not shown.
|
@ -150,9 +150,11 @@ function legacyClosest( element, selector ) {
|
||||||
*/
|
*/
|
||||||
export function findNearestEligibleTarget( element ) {
|
export function findNearestEligibleTarget( element ) {
|
||||||
const selector = selectors.join( ', ' );
|
const selector = selectors.join( ', ' );
|
||||||
if ( element.closest ) {
|
try {
|
||||||
return element.closest( selector );
|
return element.closest( selector );
|
||||||
} else {
|
} catch ( e ) {
|
||||||
|
// The browser either doesn't support the selector we gave it or doesn't
|
||||||
|
// have the closest method.
|
||||||
return legacyClosest( element, selector );
|
return legacyClosest( element, selector );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue