Skip to content

Commit 66d8da6

Browse files
committed
Change to remove support for non-nodes
1 parent 9d15d29 commit 66d8da6

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

lib/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
* Rank of the heading or `undefined` if not a heading.
1212
*/
1313
export function headingRank(node) {
14-
const name =
15-
(node && node.type === 'element' && node.tagName.toLowerCase()) || ''
14+
const name = node.type === 'element' ? node.tagName.toLowerCase() : ''
1615
const code =
1716
name.length === 2 && name.charCodeAt(0) === 104 /* `h` */
1817
? name.charCodeAt(1)

test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ test('headingRank', async function (t) {
1010
])
1111
})
1212

13-
await t.test('should return `undefined` for non-nodes', async function () {
14-
// @ts-expect-error runtime.
15-
assert.equal(headingRank(), undefined)
16-
})
17-
1813
await t.test('should return `undefined` for non-elements', async function () {
1914
assert.equal(headingRank({type: 'text', value: '!'}), undefined)
2015
})

0 commit comments

Comments
 (0)