Skip to content

Commit cb58ea7

Browse files
committed
Update unist-util-visit
1 parent 290e9dc commit cb58ea7

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

lib/index.js

+9-15
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
* @typedef {import('hast').Element} Element
1111
* @typedef {import('hast').Root} Root
1212
* @typedef {import('unist-util-position').PositionLike} PositionLike
13-
* @typedef {import('unist-util-visit').Visitor<FootnoteDefinition>} FootnoteDefinitionVisitor
1413
*
1514
* @typedef {Element|Text|Comment} Content
1615
*
@@ -95,7 +94,15 @@ function factory(tree, options) {
9594
h.unknownHandler = settings.unknownHandler
9695
h.passThrough = settings.passThrough
9796

98-
visit(tree, 'footnoteDefinition', onfootnotedefinition)
97+
visit(tree, 'footnoteDefinition', (definition) => {
98+
const id = String(definition.identifier).toUpperCase()
99+
100+
// Mimick CM behavior of link definitions.
101+
// See: <https://github.com/syntax-tree/mdast-util-definitions/blob/8290999/index.js#L26>.
102+
if (!own.call(footnoteById, id)) {
103+
footnoteById[id] = definition
104+
}
105+
})
99106

100107
// @ts-expect-error Hush, it’s fine!
101108
return h
@@ -164,19 +171,6 @@ function factory(tree, options) {
164171
children: children || []
165172
})
166173
}
167-
168-
/**
169-
* @type {FootnoteDefinitionVisitor}
170-
*/
171-
function onfootnotedefinition(definition) {
172-
const id = String(definition.identifier).toUpperCase()
173-
174-
// Mimick CM behavior of link definitions.
175-
// See: <https://github.com/syntax-tree/mdast-util-definitions/blob/8290999/index.js#L26>.
176-
if (!own.call(footnoteById, id)) {
177-
footnoteById[id] = definition
178-
}
179-
}
180174
}
181175

182176
/**

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"unist-builder": "^3.0.0",
4343
"unist-util-generated": "^2.0.0",
4444
"unist-util-position": "^4.0.0",
45-
"unist-util-visit": "^3.0.0"
45+
"unist-util-visit": "^4.0.0"
4646
},
4747
"devDependencies": {
4848
"@types/tape": "^4.0.0",

0 commit comments

Comments
 (0)