Merge pull request #13763 from calixteman/bug_1720907

XFA - Must use bindItems element even if there is no direct binding (bug 1720907)
This commit is contained in:
calixteman 2021-07-20 18:19:56 +02:00 committed by GitHub
commit bdeb41a294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 0 deletions

View File

@ -616,6 +616,8 @@ class Binder {
dataNode[$appendChild](match);
// Don't bind the value in newly created node because it's empty.
this._setProperties(child, match);
this._bindItems(child, match);
this._bindElement(child, match);
continue;
}

View File

@ -1354,5 +1354,50 @@ describe("XFAParser", function () {
expect(searchNode(data, data, "root")[0][$dump]()).toEqual(expected);
});
it("should make a binding with a bindItems", function () {
const xml = `
<?xml version="1.0"?>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
<template xmlns="http://www.xfa.org/schema/xfa-template/3.3">
<subform name="A" mergeMode="matchTemplate">
<subform name="B">
<field name="C">
<ui>
<choicelist/>
</ui>
<bindItems ref="xfa.datasets.foo.bar[*]" labelRef="$" valueRef="oof"/>
</field>
</subform>
</subform>
</template>
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
<foo>
<bar oof="a">1</bar>
<bar oof="b">2</bar>
<bar oof="c">3</bar>
<bar oof="d">4</bar>
<bar oof="e">5</bar>
</foo>
<xfa:data>
<A><B></B></A>
</xfa:data>
</xfa:datasets>
</xdp:xdp>
`;
const root = new XFAParser().parse(xml);
const form = new Binder(root).bind();
expect(
searchNode(form, form, "A.B.C.items[0].text[*]").map(
x => x[$dump]().$content
)
).toEqual(["1", "2", "3", "4", "5"]);
expect(
searchNode(form, form, "A.B.C.items[1].text[*]").map(
x => x[$dump]().$content
)
).toEqual(["a", "b", "c", "d", "e"]);
});
});
});