mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Added new types for domelementtype * Modify existing types for htmlparser2 * Updating PULL_REQUEST_TEMPLATE.md * Revert changes to .github/PULL_REQUEST_TEMPLATE.md * Fixed missing optional * Adding DomUtils * Update dependencies * Removed requirement for TypeScript 2.1 and updated test * Updated test to include DomUtils and DomHandlerOptions. * Updated domhandler tests * Remove incorrect constructor in Parser * Remove incorrect constructor in WritableStream * Change way of importing in tests * Adding deprecated fallback to Options * Add deprecated Options as a fallback to sanitize-html * Add ParserOptions * Use the deprecated Options
15 lines
670 B
TypeScript
15 lines
670 B
TypeScript
import { DomHandler, DomHandlerOptions, Node, DomElement } from "domhandler";
|
|
|
|
const handler = new DomHandler((error: Error, dom: DomElement[]) => {
|
|
if (error)
|
|
console.error('There has been an error...');
|
|
else
|
|
console.log(dom);
|
|
});
|
|
handler.ontext = (data: string) => { console.log(data); };
|
|
handler.onreset = () => { console.log('We have a reset.'); };
|
|
handler.onerror = (error: Error) => { console.error(error); };
|
|
handler.onopentag = (name: string, attribs: { [s: string]: string }) => { console.log(name, attribs); };
|
|
|
|
const dho: DomHandlerOptions = { normalizeWhitespace: true, withDomLvl1: true, withEndIndices: true, withStartIndices: true };
|