[cheerio] Adds missing load(CheerioElement) (#11520)

This commit is contained in:
Alex Gorbatchev
2016-09-30 05:44:05 -07:00
committed by Masahiro Wakame
parent 359a99c5f9
commit 8acf2ed755
2 changed files with 7 additions and 0 deletions

View File

@@ -20,6 +20,12 @@ cheerio(html);
cheerio('ul', html);
cheerio('li', 'ul', html);
const $fromElement = cheerio.load($("ul").get(0));
if ($fromElement("ul > li").length !== 3) {
throw new Error("Expecting 3 elements when passing `CheerioElement` to `load()`");
}
$ = cheerio.load(html, {
normalizeWhitespace: true,
xmlMode: true

View File

@@ -259,6 +259,7 @@ interface CheerioElement {
interface CheerioAPI extends CheerioSelector {
load(html: string, options?: CheerioOptionsInterface): CheerioStatic;
load(element: CheerioElement, options?: CheerioOptionsInterface): CheerioStatic;
}
declare var cheerio:CheerioAPI;