Skip to content

Commit d317e7a

Browse files
committed
Update unist-util-visit
1 parent 7987f71 commit d317e7a

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

lib/index.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,13 @@ export function raw(tree, file, options) {
128128
const result = fromParse5(documentMode(tree) ? document() : fragment(), file)
129129

130130
if (stitches) {
131-
visit(result, 'comment', mend)
131+
visit(result, 'comment', (node, index, parent) => {
132+
const stitch = /** @type {Stitch} */ (node)
133+
if (stitch.value.stitch && parent !== null && index !== null) {
134+
parent.children[index] = stitch.value.stitch
135+
return index
136+
}
137+
})
132138
}
133139

134140
// Unpack if possible and when not given a `root`.
@@ -142,16 +148,6 @@ export function raw(tree, file, options) {
142148

143149
return result
144150

145-
/**
146-
* @type {import('unist-util-visit').Visitor<Stitch>}
147-
*/
148-
function mend(node, index, parent) {
149-
if (node.value.stitch && parent !== null && index !== null) {
150-
parent.children[index] = node.value.stitch
151-
return index
152-
}
153-
}
154-
155151
/**
156152
* @returns {P5Fragment}
157153
*/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"html-void-elements": "^2.0.0",
4343
"parse5": "^6.0.0",
4444
"unist-util-position": "^4.0.0",
45-
"unist-util-visit": "^3.0.0",
45+
"unist-util-visit": "^4.0.0",
4646
"vfile": "^5.0.0",
4747
"web-namespaces": "^2.0.0",
4848
"zwitch": "^2.0.0"

0 commit comments

Comments
 (0)