From d317e7ad03289809496d9e64ff4375f91134fe42 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 30 Jul 2021 11:12:55 +0200 Subject: [PATCH] Update `unist-util-visit` --- lib/index.js | 18 +++++++----------- package.json | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/index.js b/lib/index.js index 4f322bb..236449f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -128,7 +128,13 @@ export function raw(tree, file, options) { const result = fromParse5(documentMode(tree) ? document() : fragment(), file) if (stitches) { - visit(result, 'comment', mend) + visit(result, 'comment', (node, index, parent) => { + const stitch = /** @type {Stitch} */ (node) + if (stitch.value.stitch && parent !== null && index !== null) { + parent.children[index] = stitch.value.stitch + return index + } + }) } // Unpack if possible and when not given a `root`. @@ -142,16 +148,6 @@ export function raw(tree, file, options) { return result - /** - * @type {import('unist-util-visit').Visitor} - */ - function mend(node, index, parent) { - if (node.value.stitch && parent !== null && index !== null) { - parent.children[index] = node.value.stitch - return index - } - } - /** * @returns {P5Fragment} */ diff --git a/package.json b/package.json index b5ce7ed..23b3391 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "html-void-elements": "^2.0.0", "parse5": "^6.0.0", "unist-util-position": "^4.0.0", - "unist-util-visit": "^3.0.0", + "unist-util-visit": "^4.0.0", "vfile": "^5.0.0", "web-namespaces": "^2.0.0", "zwitch": "^2.0.0"