From 9e403f05a69bd39409949851cde5c57c4e376d49 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 17 Nov 2023 20:39:56 +0700 Subject: [PATCH] Add TypeScript types --- index.d.ts | 9 +++++++++ index.js | 11 ----------- 2 files changed, 9 insertions(+), 11 deletions(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..88e61a5 --- /dev/null +++ b/index.d.ts @@ -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; diff --git a/index.js b/index.js index c06832a..16f9434 100644 --- a/index.js +++ b/index.js @@ -27,17 +27,6 @@ wrapMap.polyline = wrapMap.rect = wrapMap.g = [1, '', '']; -/** - * Parse `html` and return a DOM Node instance, which could be a TextNode, - * HTML DOM Node of some kind (
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');