diff --git a/src/mdn/process-html/process-playground.ts b/src/mdn/process-html/process-playground.ts
index 55684b38..a8e5c6b9 100644
--- a/src/mdn/process-html/process-playground.ts
+++ b/src/mdn/process-html/process-playground.ts
@@ -90,7 +90,7 @@ function sectionForHeading($: CheerioStatic, heading: Cheerio | null): Cheerio[]
return [...heading.children().map((_, el) => $(el))];
}
let next = heading.next();
- while (next && partOfSection(heading, next)) {
+ while (next.length && partOfSection(heading, next)) {
nodes.push(next);
if (next.next().length === 0) {
next = next.parent().next().children().first() || null;