Skip to content

Commit

Permalink
Add TypeScript types
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 17, 2023
1 parent 9c720f9 commit 9e403f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
9 changes: 9 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
Turn a HTML string into DOM elements, cross-platform.
@param htmlString - The HTML string to make into a DOM element.
@param document - The `document` instance. Required for non-browser environments.
*/
declare function domify(htmlString: string, document?: Document): Node;

export = domify;
11 changes: 0 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,6 @@ wrapMap.polyline
= wrapMap.rect
= wrapMap.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">', '</svg>'];

/**
* Parse `html` and return a DOM Node instance, which could be a TextNode,
* HTML DOM Node of some kind (<div> for example), or a DocumentFragment
* instance, depending on the contents of the `html` string.
*
* @param {String} htmlString - HTML string to "domify"
* @param {Document} doc - The `document` instance to create the Node for
* @return {DOMNode} the TextNode, DOM Node, or DocumentFragment instance
* @api private
*/

function domify(htmlString, document = globalThis.document) {
if (typeof htmlString !== 'string') {
throw new TypeError('String expected');
Expand Down

0 comments on commit 9e403f0

Please sign in to comment.