From 37546bb85efc292703289313c6c87798cd4ab20c Mon Sep 17 00:00:00 2001 From: bptato Date: Thu, 11 Apr 2024 12:32:49 +0200 Subject: renderdocument: do not layout with styledRoot == nil it can happen when do_reshape is called before any parsing happens. --- src/layout/renderdocument.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/layout/renderdocument.nim b/src/layout/renderdocument.nim index d4dc377f..06a6992a 100644 --- a/src/layout/renderdocument.nim +++ b/src/layout/renderdocument.nim @@ -450,8 +450,11 @@ proc renderBlockBox(grid: var FlexibleGrid; state: var RenderState; stack.add((box.nested[i], offset)) proc renderDocument*(grid: var FlexibleGrid; bgcolor: var CellColor; - styledRoot: StyledNode, attrsp: ptr WindowAttributes) = + styledRoot: StyledNode; attrsp: ptr WindowAttributes) = grid.setLen(0) + if styledRoot == nil: + # no HTML element when we run cascade; just clear all lines. + return var state = RenderState( absolutePos: @[Offset(x: 0, y: 0)], attrsp: attrsp -- cgit 1.4.1-2-gfad0