[jquery/findTestSubject] added docs

This commit is contained in:
spalger 2015-09-23 10:16:31 -07:00
parent 657697aa68
commit 870eb8a4a8

View file

@ -1,5 +1,44 @@
module.exports = function bindToJquery($) {
/**
* Find elements with the `data-test-subj` attribute by the terms in that attribute.
*
* Find all of the element inside $el with the "saveButton" subject.
*
* ```js
* var $button = $el.findTestSubject('saveButton');
* ```
*
* Find all of the elements with either "saveButton" or "cancelButton"
*
* ```js
* var $buttons = $.findTestSubject('saveButton', 'cancelButton');
* ```
*
* Find all of the elements with a subject that decent from another subject
*
* ```js
* var $button = $.findTestSubject('savedObjectForm saveButton');
* ```
*
* Find all of the elements which have both subjects
*
* ```js
* var $input = $.findTestSubject('smallButton&saveButton');
* ```
*
* @return {jQueryCollection}
*/
$.findTestSubject = function () {
return findTestSubject.apply($(document.body), arguments);
};
/**
* Just like $.findTestSubject, except only finds elements within another element.
* @return {jQueryCollection}
*/
$.fn.findTestSubject = findTestSubject;
function findTestSubject(/* ...subjectSelectors */) {
var subjectSelectors = [].slice.apply(arguments);
var $els = $();
@ -16,9 +55,4 @@ module.exports = function bindToJquery($) {
return $els;
};
$.fn.findTestSubject = findTestSubject;
$.findTestSubject = function () {
return findTestSubject.apply($(document.body), arguments);
};
};