From 98baf3917c152720e288626a4cb116681748dd8d Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 6 Feb 2020 23:51:50 -0500 Subject: [PATCH 1/2] docs(lib): update JSDoc in `dom-to-react` --- lib/dom-to-react.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/dom-to-react.js b/lib/dom-to-react.js index 5000a0b0..695dd2de 100644 --- a/lib/dom-to-react.js +++ b/lib/dom-to-react.js @@ -4,10 +4,11 @@ var utilities = require('./utilities'); /** * Converts DOM nodes to React elements. * - * @param {Array} nodes - The DOM nodes. - * @param {Object} [options] - The additional options. - * @param {Function} [options.replace] - The replace method. - * @return {ReactElement|Array} + * @param {DomElement[]} nodes - The DOM nodes. + * @param {Object} [options={}] - The additional options. + * @param {Function} [options.replace] - The replacer. + * @param {Object} [options.library] - The library (React, Preact, etc.). + * @return {String|ReactElement|ReactElement[]} */ function domToReact(nodes, options) { options = options || {}; @@ -95,6 +96,10 @@ function domToReact(nodes, options) { return result.length === 1 ? result[0] : result; } +/** + * @param {React.ReactElement} node + * @return {Boolean} + */ function shouldPassAttributesUnaltered(node) { return ( utilities.PRESERVE_CUSTOM_ATTRIBUTES && From 801512ba353e46ba931ee018ea8a9ec6c2d5da60 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 7 Feb 2020 23:50:25 -0500 Subject: [PATCH 2/2] fix(index): make `replace` property optional in `index.d.ts` And update the return types See #134 --- index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 120a7727..4078e738 100644 --- a/index.d.ts +++ b/index.d.ts @@ -7,7 +7,9 @@ import htmlToDOM from 'html-dom-parser'; export interface HTMLReactParserOptions { // TODO: Replace `object` by type for objects like `{ type: 'h1', props: { children: 'Heading' } }` - replace(domNode: DomElement): React.ReactElement | object | undefined | false; + replace?: ( + domNode: DomElement + ) => React.ReactElement | object | void | undefined | null | false; library?: object; }