Skip to content

Commit b7fc859

Browse files
committed
Update @types/hast, utilities
1 parent 32e8aee commit b7fc859

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

lib/index.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1-
/**
2-
* @typedef {import('hast').Element} Element
3-
*/
4-
51
import {convertElement} from 'hast-util-is-element'
62

73
/**
84
* Check if a node is sectioning content.
95
*
10-
* @type {import('hast-util-is-element').AssertPredicate<Element & {tagName: 'article' | 'aside' | 'nav' | 'section'}>}
116
* @param value
127
* Thing to check (typically `Node`).
138
* @returns
149
* Whether `value` is an element considered sectioning content.
1510
*
1611
* The elements `article`, `aside`, `nav`, and `section` are sectioning.
1712
*/
18-
// @ts-expect-error Sure, the assertion matches.
19-
export const sectioning = convertElement(['article', 'aside', 'nav', 'section'])
13+
export const sectioning = convertElement(
14+
/**
15+
* @param element
16+
* @returns {element is {tagName: 'article' | 'aside' | 'nav' | 'section'}}
17+
*/
18+
function (element) {
19+
return (
20+
element.tagName === 'article' ||
21+
element.tagName === 'aside' ||
22+
element.tagName === 'nav' ||
23+
element.tagName === 'section'
24+
)
25+
}
26+
)

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
"index.js"
3434
],
3535
"dependencies": {
36-
"@types/hast": "^2.0.0",
37-
"hast-util-is-element": "^2.0.0"
36+
"hast-util-is-element": "^3.0.0"
3837
},
3938
"devDependencies": {
4039
"@types/node": "^20.0.0",

test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ test('sectioning', () => {
1010
'should expose the public api'
1111
)
1212

13+
// @ts-expect-error: check how a missing `node` is handled.
1314
assert.equal(sectioning(), false, 'should return `false` without node')
1415

1516
assert.equal(sectioning(null), false, 'should return `false` with `null`')

0 commit comments

Comments
 (0)