[Annotation] Strip out the array index in the path only when the path is from a terminal node (bug 1847733)
This commit is contained in:
parent
19c712c2d0
commit
e2f20a1afe
@ -1630,7 +1630,8 @@ class WidgetAnnotation extends Annotation {
|
||||
if (
|
||||
data.fieldName &&
|
||||
/\[\d+\]$/.test(data.fieldName) &&
|
||||
!dict.has("Kids")
|
||||
!dict.has("Kids") &&
|
||||
dict.has("T")
|
||||
) {
|
||||
data.baseFieldName = data.fieldName.substring(
|
||||
0,
|
||||
|
@ -1711,7 +1711,7 @@ class PDFDocument {
|
||||
name = name === "" ? partName : `${name}.${partName}`;
|
||||
}
|
||||
|
||||
if (!field.has("Kids") && /\[\d+\]$/.test(name)) {
|
||||
if (!field.has("Kids") && field.has("T") && /\[\d+\]$/.test(name)) {
|
||||
// We've a terminal node: strip the index.
|
||||
name = name.substring(0, name.lastIndexOf("["));
|
||||
}
|
||||
|
@ -160,6 +160,37 @@ describe("Checkbox annotation", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("bug1847733.pdf", () => {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait("bug1847733.pdf", "[data-annotation-id='18R']");
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must check the checkbox", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
const selectors = [18, 30, 42, 54].map(
|
||||
id => `[data-annotation-id='${id}R']`
|
||||
);
|
||||
for (const selector of selectors) {
|
||||
await page.click(selector);
|
||||
page.waitForTimeout(10);
|
||||
}
|
||||
for (const selector of selectors) {
|
||||
await page.waitForFunction(
|
||||
`document.querySelector("${selector} > :first-child").checked`
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Text widget", () => {
|
||||
|
2
test/pdfs/bug1847733.pdf.link
Normal file
2
test/pdfs/bug1847733.pdf.link
Normal file
@ -0,0 +1,2 @@
|
||||
https://github.com/mozilla/pdf.js/files/12290354/PDF.Form.4.pdf
|
||||
|
@ -8070,5 +8070,13 @@
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"print": true
|
||||
},
|
||||
{
|
||||
"id": "bug1847733",
|
||||
"file": "pdfs/bug1847733.pdf",
|
||||
"md5": "d2e167216493a50f732b4b3685a91792",
|
||||
"rounds": 1,
|
||||
"link": true,
|
||||
"type": "other"
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user