mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #14073 from calixteman/bindItems
XFA - Bind items when there's a bindItems entry
This commit is contained in:
commit
104e049338
2 changed files with 63 additions and 10 deletions
|
@ -1259,6 +1259,57 @@ describe("XFAParser", function () {
|
|||
]);
|
||||
});
|
||||
|
||||
it("should make binding and bind items with a ref", 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="main">
|
||||
<field name="CardName">
|
||||
<bind match="dataRef" ref="$data.main.value"/>
|
||||
<bindItems ref="$data.main.ccs.cc[*]" labelRef="uiname" valueRef="token"/>
|
||||
<ui>
|
||||
<choiceList/>
|
||||
</ui>
|
||||
</field>
|
||||
</subform>
|
||||
</template>
|
||||
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
|
||||
<xfa:data>
|
||||
<main>
|
||||
<value>VISA</value>
|
||||
<ccs>
|
||||
<cc uiname="Visa" token="VISA"/>
|
||||
<cc uiname="Mastercard" token="MC"/>
|
||||
<cc uiname="American Express" token="AMEX"/>
|
||||
</ccs>
|
||||
<CardName>MC</CardName>
|
||||
</main>
|
||||
</xfa:data>
|
||||
</xfa:datasets>
|
||||
</xdp:xdp>
|
||||
`;
|
||||
const root = new XFAParser().parse(xml);
|
||||
const form = new Binder(root).bind();
|
||||
expect(
|
||||
searchNode(form, form, "subform.CardName.value.text").map(x =>
|
||||
x[$text]()
|
||||
)
|
||||
).toEqual(["VISA"]);
|
||||
expect(
|
||||
searchNode(form, form, "subform.CardName.items[*].text[*]").map(x =>
|
||||
x[$text]()
|
||||
)
|
||||
).toEqual([
|
||||
"Visa",
|
||||
"Mastercard",
|
||||
"American Express",
|
||||
"VISA",
|
||||
"MC",
|
||||
"AMEX",
|
||||
]);
|
||||
});
|
||||
|
||||
it("should make binding with occurrences in consumeData mode", function () {
|
||||
const xml = `
|
||||
<?xml version="1.0"?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue