From 8acf2ed755604e8602aa9f2f8d5942b55b8dceae Mon Sep 17 00:00:00 2001 From: Alex Gorbatchev Date: Fri, 30 Sep 2016 05:44:05 -0700 Subject: [PATCH] [cheerio] Adds missing load(CheerioElement) (#11520) --- cheerio/cheerio-tests.ts | 6 ++++++ cheerio/cheerio.d.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/cheerio/cheerio-tests.ts b/cheerio/cheerio-tests.ts index c1b5eda894..f6b184be8e 100644 --- a/cheerio/cheerio-tests.ts +++ b/cheerio/cheerio-tests.ts @@ -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 diff --git a/cheerio/cheerio.d.ts b/cheerio/cheerio.d.ts index afc8ebaa71..e94eb1a68c 100644 --- a/cheerio/cheerio.d.ts +++ b/cheerio/cheerio.d.ts @@ -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;