-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
97 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
// TypeScript Version: 4.1 | ||
|
||
import { DomElement } from 'domhandler'; | ||
import { DataNode, Element } from 'domhandler'; | ||
|
||
/** | ||
* Parses HTML string to DOM nodes in browser. | ||
* | ||
* @param html - HTML markup. | ||
* @return - DOM elements. | ||
*/ | ||
export default function HTMLDOMParser(html: string): DomElement[]; | ||
export default function HTMLDOMParser(html: string): Array<DataNode | Element>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// TypeScript Version: 4.1 | ||
|
||
import { DomHandlerOptions, DomElement } from 'domhandler'; | ||
import { DataNode, DomHandlerOptions, Element } from 'domhandler'; | ||
|
||
/** | ||
* Parses HTML string to DOM nodes in Node.js. | ||
* | ||
* This is the same method as `require('htmlparser2').parseDOM` | ||
* https://github.com/fb55/htmlparser2/blob/v3.9.1/lib/index.js#L39-L43 | ||
* https://github.com/fb55/htmlparser2/blob/v4.0.0/src/index.ts#L18-L22 | ||
* | ||
* @param html - HTML markup. | ||
* @param options - Parser options (https://github.com/fb55/domhandler/tree/v2.4.2#readme). | ||
* @param options - Parser options (https://github.com/fb55/domhandler/tree/v3.0.0#readme). | ||
* @return - DOM elements. | ||
*/ | ||
export default function HTMLDOMParser( | ||
html: string, | ||
options?: DomHandlerOptions | ||
): DomElement[]; | ||
): Array<DataNode | Element>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
import parseDOM from 'html-dom-parser'; | ||
import parse from 'html-dom-parser'; | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM('<div>text</div>'); | ||
// $ExpectType (DataNode | Element)[] | ||
parse('<div>text</div>'); | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM('<div>text</div>', { normalizeWhitespace: true }); | ||
// $ExpectType (DataNode | Element)[] | ||
parse('<div>text</div>', { normalizeWhitespace: true }); | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM('<div>text</div>', { withDomLvl1: true }); | ||
// $ExpectType (DataNode | Element)[] | ||
parse('<div>text</div>', { withStartIndices: true }); | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM('<div>text</div>', { withStartIndices: true }); | ||
// $ExpectType (DataNode | Element)[] | ||
parse('<div>text</div>', { withEndIndices: true }); | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM('<div>text</div>', { withEndIndices: true }); | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM(''); | ||
// $ExpectType (DataNode | Element)[] | ||
parse(''); |