Skip to content

Commit

Permalink
Change to remove support for non-nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 2, 2023
1 parent 9d15d29 commit 66d8da6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
3 changes: 1 addition & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
* Rank of the heading or `undefined` if not a heading.
*/
export function headingRank(node) {
const name =
(node && node.type === 'element' && node.tagName.toLowerCase()) || ''
const name = node.type === 'element' ? node.tagName.toLowerCase() : ''
const code =
name.length === 2 && name.charCodeAt(0) === 104 /* `h` */
? name.charCodeAt(1)
Expand Down
5 changes: 0 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ test('headingRank', async function (t) {
])
})

await t.test('should return `undefined` for non-nodes', async function () {
// @ts-expect-error runtime.
assert.equal(headingRank(), undefined)
})

await t.test('should return `undefined` for non-elements', async function () {
assert.equal(headingRank({type: 'text', value: '!'}), undefined)
})
Expand Down

0 comments on commit 66d8da6

Please sign in to comment.