File tree Expand file tree Collapse file tree 2 files changed +1
-7
lines changed Expand file tree Collapse file tree 2 files changed +1
-7
lines changed Original file line number Diff line number Diff line change 11
11
* Rank of the heading or `undefined` if not a heading.
12
12
*/
13
13
export function headingRank ( node ) {
14
- const name =
15
- ( node && node . type === 'element' && node . tagName . toLowerCase ( ) ) || ''
14
+ const name = node . type === 'element' ? node . tagName . toLowerCase ( ) : ''
16
15
const code =
17
16
name . length === 2 && name . charCodeAt ( 0 ) === 104 /* `h` */
18
17
? name . charCodeAt ( 1 )
Original file line number Diff line number Diff line change @@ -10,11 +10,6 @@ test('headingRank', async function (t) {
10
10
] )
11
11
} )
12
12
13
- await t . test ( 'should return `undefined` for non-nodes' , async function ( ) {
14
- // @ts -expect-error runtime.
15
- assert . equal ( headingRank ( ) , undefined )
16
- } )
17
-
18
13
await t . test ( 'should return `undefined` for non-elements' , async function ( ) {
19
14
assert . equal ( headingRank ( { type : 'text' , value : '!' } ) , undefined )
20
15
} )
You can’t perform that action at this time.
0 commit comments