Previously, Pjax would blur (remove focus) from the active element regardless of where it was on the page. This restricts that to happen only if the active element is contained by one of the elements represented by options.selectors, because only those are affected by Pjax. Fixes #4
13 lines
309 B
JavaScript
13 lines
309 B
JavaScript
module.exports = function contains(doc, selectors, el) {
|
|
for (var i = 0; i < selectors.length; i++) {
|
|
var selectedEls = doc.querySelectorAll(selectors[i])
|
|
for (var j = 0; j < selectedEls.length; j++) {
|
|
if (selectedEls[j].contains(el)) {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|