From f168998d93a6ca58af2459e737ca8bdcd9565ab0 Mon Sep 17 00:00:00 2001
From: Calixte Denizet <calixte.denizet@gmail.com>
Date: Wed, 23 Jun 2021 19:42:36 +0200
Subject: [PATCH] XFA - Add back empty subforms (which can have a background)

---
 src/core/xfa/template.js | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js
index 237667e92..b8cd672e2 100644
--- a/src/core/xfa/template.js
+++ b/src/core/xfa/template.js
@@ -2154,10 +2154,6 @@ class ExclGroup extends XFAObject {
       return HTMLResult.FAILURE;
     }
 
-    if (children.length === 0) {
-      return HTMLResult.EMPTY;
-    }
-
     let marginH = 0;
     let marginV = 0;
     if (this.margin) {
@@ -4337,10 +4333,6 @@ class Subform extends XFAObject {
       return HTMLResult.FAILURE;
     }
 
-    if (children.length === 0) {
-      return HTMLResult.EMPTY;
-    }
-
     let marginH = 0;
     let marginV = 0;
     if (this.margin) {
@@ -4649,7 +4641,8 @@ class Template extends XFAObject {
       const flush = index => {
         const html = root[$flushHTML]();
         if (html) {
-          hasSomething = true;
+          hasSomething =
+            hasSomething || (html.children && html.children.length !== 0);
           htmlContentAreas[index].children.push(html);
         }
       };
@@ -4671,7 +4664,9 @@ class Template extends XFAObject {
         const html = root[$toHTML](space);
         if (html.success) {
           if (html.html) {
-            hasSomething = true;
+            hasSomething =
+              hasSomething ||
+              (html.html.children && html.html.children.length !== 0);
             htmlContentAreas[i].children.push(html.html);
           } else if (!hasSomething) {
             mainHtml.children.pop();