🤖 Merge PR #64731 commonmark: include null as possibility for NodeWalker.next by @zombiezen

* commonmark: include null as possibility for NodeWalker.next

* Update test

* Fix initial part of test
This commit is contained in:
Ross Light
2023-03-25 12:57:45 -07:00
committed by GitHub
parent 84e4c35de6
commit 4396dbcb54
2 changed files with 4 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ const node = parser.parse('# a piece of _markdown_');
const w = node.walker();
const step = w.next();
if (step.entering) {
if (step?.entering) {
logNode(step.node);
}
@@ -70,7 +70,7 @@ function soft_breaks_as_spaces() {
function text_to_ALL_CAPS(parsed: commonmark.Node) {
const walker = parsed.walker();
let event: commonmark.NodeWalkingStep;
let event: commonmark.NodeWalkingStep | null;
let node: commonmark.Node;
event = walker.next();
@@ -85,7 +85,7 @@ function text_to_ALL_CAPS(parsed: commonmark.Node) {
function emphasis_to_ALL_CAPS(parsed: commonmark.Node) {
const walker = parsed.walker();
let event: commonmark.NodeWalkingStep;
let event: commonmark.NodeWalkingStep | null;
let node: commonmark.Node;
let inEmph = false;

View File

@@ -178,7 +178,7 @@ export interface NodeWalker {
/**
* Returns an object with properties entering and node. Returns null when we have finished walking the tree.
*/
next(): NodeWalkingStep;
next(): NodeWalkingStep | null;
/**
* Resets the iterator to resume at the specified node and setting for entering. (Normally this isn't needed unless you do destructive updates to the Node tree.)
*/