mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[jquery/findTestSubject] added support for compound subjects
This commit is contained in:
parent
870eb8a4a8
commit
f1a9069b35
1 changed files with 16 additions and 5 deletions
21
src/ui/public/jquery/findTestSubject.js
vendored
21
src/ui/public/jquery/findTestSubject.js
vendored
|
@ -44,12 +44,23 @@ module.exports = function bindToJquery($) {
|
|||
var $els = $();
|
||||
var $context = this;
|
||||
|
||||
subjectSelectors.forEach(function (subjects) {
|
||||
var selector = subjects.split(/\s+/).map(function (subject) {
|
||||
return '[data-test-subj~="' + subject + '"]';
|
||||
}).join(' ');
|
||||
subjectSelectors.forEach(function (subjectSelector) {
|
||||
var cssSelectors = [];
|
||||
var terms = subjectSelector
|
||||
.replace(/\s*&\s*/g, '&') // remove all whitespace around joins
|
||||
.split(/\s+/);
|
||||
|
||||
$els = $els.add($context.find(selector));
|
||||
function termToCssSelector(term) {
|
||||
return term ? '[data-test-subj~="' + term + '"]' : '';
|
||||
}
|
||||
|
||||
while (terms.length) {
|
||||
var term = terms.shift();
|
||||
// split each term by joins/& and map to css selectors
|
||||
cssSelectors.push(term.split('&').map(termToCssSelector).join(''));
|
||||
}
|
||||
|
||||
$els = $els.add($context.find(cssSelectors.join(' ')));
|
||||
});
|
||||
|
||||
return $els;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue