mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 20:39:17 +08:00
[cheerio] Adds missing load(CheerioElement) (#11520)
This commit is contained in:
committed by
Masahiro Wakame
parent
359a99c5f9
commit
8acf2ed755
@@ -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
|
||||
|
||||
1
cheerio/cheerio.d.ts
vendored
1
cheerio/cheerio.d.ts
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user