Add ability to create element without using load

This commit is contained in:
Almouro
2015-08-16 12:12:50 +02:00
parent 5109e1269d
commit 5d0102d544
2 changed files with 15 additions and 6 deletions
+2
View File
@@ -2,6 +2,8 @@
import cheerio = require("cheerio");
cheerio('<html></html>');
var $ = cheerio.load("<html></html>");
var $el = $('selector');
var $multiEl = $('seletor', 'selector', 'selector');
+13 -6
View File
@@ -172,11 +172,7 @@ interface CheerioOptionsInterface {
normalizeWhitespace?: boolean;
}
interface CheerioStatic {
// Document References
// Cheerio https://github.com/cheeriojs/cheerio
// JQuery http://api.jquery.com
interface CheerioSelector {
(selector: string): Cheerio;
(selector: string, context: string): Cheerio;
(selector: string, context: CheerioElement): Cheerio;
@@ -187,7 +183,12 @@ interface CheerioStatic {
(selector: string, context: CheerioElement[], root: string): Cheerio;
(selector: string, context: Cheerio, root: string): Cheerio;
(selector: any): Cheerio;
}
interface CheerioStatic extends CheerioSelector {
// Document References
// Cheerio https://github.com/cheeriojs/cheerio
// JQuery http://api.jquery.com
xml(): string;
root(): Cheerio;
contains(container: CheerioElement, contained: CheerioElement): boolean;
@@ -213,6 +214,12 @@ interface CheerioElement {
root: CheerioElement;
}
interface CheerioAPI extends CheerioSelector {
load(html: string, options?: CheerioOptionsInterface): CheerioStatic;
}
declare var cheerio:CheerioAPI;
declare module "cheerio" {
export function load(html: string, options?: CheerioOptionsInterface): CheerioStatic;
export = CheerioAPI;
}