File tree Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Original file line number Diff line number Diff line change 1818 * Heading node to check.
1919 * @param {Style | null | undefined } [relative]
2020 * Relative style (preferred style).
21- * @returns {Style | null }
22- * Style, if it can be inferred, `null ` otherwise.
21+ * @returns {Style | undefined }
22+ * Style, if it can be inferred, `undefined ` otherwise.
2323 */
24- // To do: next major: use `undefined`.
2524export function headingStyle ( node , relative ) {
2625 const last = node . children [ node . children . length - 1 ]
2726 const depth = node . depth
2827 const pos = node . position && node . position . end
2928 const final = last && last . position && last . position . end
3029
3130 if ( ! pos ) {
32- return null
31+ return undefined
3332 }
3433
3534 // This can only occur for `'atx'` and `'atx-closed'` headings.
@@ -59,12 +58,12 @@ export function headingStyle(node, relative) {
5958 *
6059 * @param {number } depth
6160 * @param {Style | null | undefined } relative
62- * @returns {Style | null }
61+ * @returns {Style | undefined }
6362 */
6463function consolidate ( depth , relative ) {
6564 return depth < 3
6665 ? 'atx'
6766 : relative === 'atx' || relative === 'setext'
6867 ? relative
69- : null
68+ : undefined
7069}
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ headingStyle(fromMarkdown('# ATX').children[0]) // => 'atx'
7777headingStyle (fromMarkdown (' # ATX #\n ' ).children [0 ]) // => 'atx-closed'
7878headingStyle (fromMarkdown (' ATX\n ===' ).children [0 ]) // => 'setext'
7979
80- headingStyle (fromMarkdown (' ### ATX' ).children [0 ]) // => null
80+ headingStyle (fromMarkdown (' ### ATX' ).children [0 ]) // => undefined
8181headingStyle (fromMarkdown (' ### ATX' ).children [0 ], ' setext' ) // => 'setext'
8282```
8383
@@ -103,7 +103,7 @@ considered setext.
103103
104104###### Returns
105105
106- Style ([ ` Style ` ] [ api-style ] ) if it can be inferred, ` null ` otherwise.
106+ Style ([ ` Style ` ] [ api-style ] ) if it can be inferred, ` undefined ` otherwise.
107107
108108### ` Style `
109109
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ test('headingStyle', async function (t) {
2828 type : 'heading' ,
2929 children : [ { type : 'text' , value : 'foo' } ]
3030 } ) ,
31- null
31+ undefined
3232 )
3333 } )
3434
@@ -45,7 +45,7 @@ test('headingStyle', async function (t) {
4545 } )
4646
4747 await t . test ( 'should work on ambiguous nodes' , async function ( ) {
48- assert . equal ( headingStyle ( parseFirstNode ( '### ATX' ) ) , null )
48+ assert . equal ( headingStyle ( parseFirstNode ( '### ATX' ) ) , undefined )
4949 } )
5050
5151 await t . test (
You can’t perform that action at this time.
0 commit comments