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

add after, before, slice arguments into jsdoc. #1721

Merged
merged 5 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/api/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ exports.wrapAll = function (wrapper) {
return this;
};

/*eslint-disable jsdoc/check-param-names*/

/**
* Insert content next to each element in the set of matched elements.
*
Expand All @@ -497,6 +499,9 @@ exports.wrapAll = function (wrapper) {
* // <li class="pear">Pear</li>
* // </ul>
*
* @param {...(string | Element | Element[] | Cheerio | Function)} content -
* HTML string, DOM element, array of DOM elements or Cheerio to insert after
* each element in the set of matched elements.
* @see {@link https://api.jquery.com/after/}
*
* @returns {Cheerio} The instance itself.
Expand Down Expand Up @@ -529,6 +534,8 @@ exports.after = function () {
});
};

/*eslint-enable jsdoc/check-param-names*/

/**
* Insert every element in the set of matched elements after the target.
*
Expand Down Expand Up @@ -580,6 +587,8 @@ exports.insertAfter = function (target) {
return this.constructor.call(this.constructor, this._makeDomArray(clones));
};

/*eslint-disable jsdoc/check-param-names*/

/**
* Insert content previous to each element in the set of matched elements.
*
Expand All @@ -593,6 +602,9 @@ exports.insertAfter = function (target) {
* // <li class="pear">Pear</li>
* // </ul>
*
* @param {...(string | Element | Element[] | Cheerio | Function)} content -
* HTML string, DOM element, array of DOM elements or Cheerio to insert
* before each element in the set of matched elements.
* @see {@link https://api.jquery.com/before/}
*
* @returns {Cheerio} The instance itself.
Expand Down Expand Up @@ -625,6 +637,8 @@ exports.before = function () {
});
};

/*eslint-enable jsdoc/check-param-names*/

/**
* Insert every element in the set of matched elements before the target.
*
Expand Down
14 changes: 10 additions & 4 deletions lib/api/traversing.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var utils = require('../utils');
var domEach = utils.domEach;
var uniqueSort = require('htmlparser2').DomUtils.uniqueSort;
var isTag = utils.isTag;
var slice = Array.prototype.slice;
var reSiblingSelector = /^\s*[~+]/;

/**
Expand Down Expand Up @@ -805,7 +806,7 @@ exports.eq = function (i) {
*/
exports.get = function (i) {
if (i == null) {
return Array.prototype.slice.call(this);
return slice.call(this);
}
return this[i < 0 ? this.length + i : i];
};
Expand Down Expand Up @@ -845,7 +846,7 @@ exports.index = function (selectorOrNeedle) {
};

/**
* Gets the elements matching the specified range.
* Gets the elements matching the specified range (0-based position).
*
* @example
* $('li').slice(1).eq(0).text();
Expand All @@ -854,12 +855,17 @@ exports.index = function (selectorOrNeedle) {
* $('li').slice(1, 2).length;
* //=> 1
*
* @param {number} [start] - An position at which the elements begin to be
* selected. If negative, it indicates an offset from the end of the set.
* @param {number} [end] - An position at which the elements stop being
* selected. If negative, it indicates an offset from the end of the set. If
* omitted, the range continues until the end of the set.
* @see {@link https://api.jquery.com/slice/}
*
* @returns {Cheerio} The elements matching the specified range.
*/
exports.slice = function () {
return this._make([].slice.apply(this, arguments));
exports.slice = function (start, end) {
return this._make(slice.call(this, start, end));
};

function traverseParents(self, elem, selector, limit) {
Expand Down