-
-
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.
feat(types): add TypeScript decelerations
- Loading branch information
1 parent
a7f99fd
commit b52d52f
Showing
10 changed files
with
104 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// TypeScript Version: 3.3 | ||
|
||
import htmlToDomServer from './lib/html-to-dom-server'; | ||
export default htmlToDomServer; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import parseDOM from 'html-dom-parser'; | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM('<div>text</div>'); | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM('<div>text</div>', { normalizeWhitespace: true }); | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM('<div>text</div>', { withDomLvl1: true }); | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM('<div>text</div>', { withStartIndices: true }); | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM('<div>text</div>', { withEndIndices: true }); | ||
|
||
// $ExpectType DomElement[] | ||
parseDOM(''); |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Parses HTML string to DOM nodes. | ||
* | ||
* @param - Raw string of HTML to parse. | ||
* @returns NodeList or empty array. | ||
*/ | ||
export default function parseDOM(html: string): NodeList | []; |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { DomElement } from 'domhandler'; | ||
|
||
/** | ||
* Parses HTML and reformats DOM nodes output. | ||
* | ||
* @param - Raw string of HTML to parse. | ||
* @returns Parsed DomElements. | ||
*/ | ||
export default function parseDOM(html: string): DomElement[]; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { DomHandlerOptions, DomElement } from 'domhandler'; | ||
|
||
/** | ||
* Parses HTML string to DOM nodes (server). | ||
* | ||
* @remarks | ||
* This is the same method as `require('htmlparser2').parseDOM` | ||
* https://github.com/fb55/htmlparser2/blob/v3.9.1/lib/index.js#L39-L43 | ||
* | ||
* @param - Raw string of HTML to parse. | ||
* @param - Options to pass to domhandler (See https://github.com/fb55/DomHandler#readme). | ||
* @returns Parsed DomElements. | ||
*/ | ||
export default function parseDOM(html: string, options?: DomHandlerOptions): DomElement[]; |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { DomElement } from 'domhandler'; | ||
|
||
/** | ||
* Format DOM attributes to an associative array. | ||
* | ||
* @param attributes - The list of attributes to format. | ||
* @returns An object mapping attributes names to values. | ||
*/ | ||
export function formatAttributes(attributes: NamedNodeMap): {[name: string]: string}; | ||
|
||
/** | ||
* Format the browser DOM nodes to mimic the output of `htmlparser2.parseDOM()`. | ||
* | ||
* @param nodes - The DOM nodes to format. | ||
* @param parentObj - The formatted parent node of the given DOM nodes. | ||
* @param directive - The directive. | ||
*/ | ||
export function formatDOM(nodes: NodeList, parentObj?: DomElement, directive?: string): DomElement[]; | ||
|
||
/** | ||
* Detect IE with or without version. | ||
* | ||
* @param version The IE version to detect. | ||
* @returns Whether IE or the version has been detected. | ||
*/ | ||
export function isIE(version: number): boolean; |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": ["es6", "dom"], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"noEmit": true, | ||
"baseUrl": ".", | ||
"paths": { "html-dom-parser": ["."], "html-dom-parser/*": ["./*"] } | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "dtslint/dtslint.json", | ||
"rules": { | ||
"semicolon": false, | ||
"indent": [true, "tabs"] | ||
} | ||
} |