From 328383ea7a4c64c741e36a54e2eb5948a7420f37 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Fri, 6 Aug 2021 18:54:42 +0200 Subject: [PATCH] XFA - Elements under an area must be bound (bug 1723734) - aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1723734. --- src/core/xfa/template.js | 13 +++++++++++++ test/unit/xfa_parser_spec.js | 26 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index 9fb3bf6ee..e2c42e6a5 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -503,6 +503,10 @@ class Area extends XFAObject { return true; } + [$isBindable]() { + return true; + } + [$addHTML](html, bbox) { const [x, y, w, h] = bbox; this[$extra].width = Math.max(this[$extra].width, x + w); @@ -2869,6 +2873,11 @@ class Field extends XFAObject { } if (value) { + if (this.ui.numericEdit) { + value = parseFloat(value); + value = isNaN(value) ? "" : value.toString(); + } + if (ui.children[0].name === "textarea") { ui.children[0].attributes.textContent = value; } else { @@ -5166,6 +5175,10 @@ class SubformSet extends XFAObject { } return parent; } + + [$isBindable]() { + return true; + } } class SubjectDN extends ContentObject { diff --git a/test/unit/xfa_parser_spec.js b/test/unit/xfa_parser_spec.js index 3f04586c8..8ef286822 100644 --- a/test/unit/xfa_parser_spec.js +++ b/test/unit/xfa_parser_spec.js @@ -1400,4 +1400,30 @@ describe("XFAParser", function () { ).toEqual(["a", "b", "c", "d", "e"]); }); }); + + it("should make a binding with a element in an area", function () { + const xml = ` + + + + + + foobar + + + + `; + const root = new XFAParser().parse(xml); + const form = new Binder(root).bind(); + + expect(searchNode(form, form, "A..B..text")[0][$dump]().$content).toBe( + "foobar" + ); + }); });