Repository navigation
Conversation
3ea190f to
487e28b
Compare
|
Tell me if an integration test is needed for this issue. |
487e28b to
ca2320b
Compare
area elements to data nodes (issue 21904)
Viewer previewCommit d91ced2 (build logs).
🔒 A user with write access must approve this commit with the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #22117 +/- ##
==========================================
+ Coverage 90.23% 90.46% +0.22%
==========================================
Files 277 277
Lines 67807 68278 +471
==========================================
+ Hits 61186 61765 +579
+ Misses 6621 6513 -108
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Failing test runs on my pc. Probably a flaky one. |
calixteman
left a comment
There was a problem hiding this comment.
The fix looks good to me. A few comments about the tests:
- Please move them into the Bind data into form block in test/unit/xfa_parser_spec.js. Those tests use Binder and searchNode directly; there's already one with an (unnamed) area at the end of the file, which is a good starting point. Going through XFAFactory, the HTML output and serializeData needs a custom tree walk, and the dataId !== fieldId check depends on the internals of html.js.
- Of the 4 tests, only the first one fails without the patch:
- the unnamed subform tests (with or without dataRef) go through code this patch doesn't change, so they can be dropped;
- the "fields of an area" test only passes on master because, in consumeData mode, an unmatched container with min > 0 falls back to the parent data node. With mergeMode="matchTemplate" it does fail without the patch: a data node named after the area is created and the field is bound to it, so the existing data is never used. Please switch it to matchTemplate, and also check that no data node was created for the area (binder.getData()).
So two tests should be enough: the area/subform name clash from the issue, and a named area in matchTemplate mode. Please make sure both fail without your change.
An integration test isn't needed for this.
An `area` is only a layout container, however it was bound to data like a subform, i.e. by looking for a data node with the same name in the current data node, its parent and its grandparent. Hence, an `area` could consume a data node meant for a subform having the same name, which was then left without any data node. Fields inside that subform were never linked to the data, so their values were lost when saving the document. Now, transparent nodes (unnamed nodes and `area` elements) are never matched with a data node and their children are bound against the data node of the enclosing container. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
ca2320b to
d91ced2
Compare
|
I moved the tests to the |
Merging this PR will not alter performance
Comparing |
Reference testsResults for d91ced2 (run, references from mozilla/pdf.js.refs@6cc7acf45c).
The report is kept for 30 days and replaced by the next run. Problems on LinuxProblems on Windows |
Fixes #21904
An
areais only a layout container, however the XFA binder treated it like a subform and matched it by name: it looked for a data node with the same name in the current data node, its parent and its grandparent, and marked the match as consumed.In the PDF from the issue there is an
<area name="Pretensao">(insideSubformPret1) and, later on, a<subform name="Pretensao">containing the "Requer o seguinte" textarea (Pret2). The area took thePretensaodata node first, hence the subform found nothing to bind to andPret2was never linked to its data node. Since values are saved by writing them into the linked data nodes, the text typed in that field was lost when saving. TheDropDownList1field in the area was affected too.Now transparent nodes (unnamed nodes and
areaelements, see$isTransparent) are never matched with a data node, and their children are bound against the data node of the enclosing container.Test cases
Bind data into formblock oftest/unit/xfa_parser_spec.js; both fail without the patch and pass with it:areaand asubformsharing the same name: thesubformis bound to its data node;areainmatchTemplatemode: its fields are bound to the data of its parent and no data node is created for thearea.