Issue: renderedDocument is cached after the first render. If new elements are added later, renderDocument() still returns the old cached value because renderedDocument is no longer empty.
string renderDocument() {
if (renderedDocument.empty()) {
renderedDocument = document->render();
}
return renderedDocument;
}
Fix: Clear the cache (or mark it dirty) whenever the document is modified so the next call re-renders the updated document.
Issue:
renderedDocumentis cached after the first render. If new elements are added later,renderDocument()still returns the old cached value becauserenderedDocumentis no longer empty.Fix: Clear the cache (or mark it dirty) whenever the document is modified so the next call re-renders the updated document.