Skip to content

Commit cd0abcd

Browse files
committed
Fix types to always pass node to afterTransform
1 parent e8db600 commit cd0abcd

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Diff for: lib/index.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@
99
* @typedef {HastChild|HastRoot} HastNode
1010
*
1111
* @callback AfterTransform
12-
* Function called when a DOM node is transformed into a hast node
12+
* Called when a DOM node was transformed into a hast node.
1313
* @param {Node} domNode
14-
* The DOM node that was handled
15-
* @param {HastNode|undefined} hastNode
16-
* The corresponding hast node
14+
* DOM node that was transformed.
15+
* @param {HastNode} hastNode
16+
* hast node the transform yielded.
1717
* @returns {void}
18+
* Nothing.
1819
*
1920
* @typedef Options
2021
* @property {AfterTransform} [afterTransform]
21-
* Function called after a DOM node is transformed into a hast node.
22-
* Given the DOM node that was handled as the first parameter and the
23-
* corresponding hast node as the second parameter.
22+
* Called when a DOM node was transformed into a hast node.
2423
*/
2524

2625
import {webNamespaces} from 'web-namespaces'
@@ -56,7 +55,7 @@ export function fromDom(node, options = {}) {
5655
*/
5756
function transform(node, ctx) {
5857
const transformed = one(node, ctx)
59-
if (ctx.afterTransform) ctx.afterTransform(node, transformed)
58+
if (ctx.afterTransform && transformed) ctx.afterTransform(node, transformed)
6059
return transformed
6160
}
6261

0 commit comments

Comments
 (0)