1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Merge pull request #19691 from Snuffleupagus/xfa-template-rm-reduce

Remove `Array.prototype.reduce` usage from the `src/core/xfa/template.js` file
This commit is contained in:
Jonas Jenwald 2025-03-25 18:17:12 +01:00 committed by GitHub
commit 22107145df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5721,12 +5721,7 @@ class Text extends ContentObject {
if (typeof this[$content] === "string") {
return this[$content]
.split(/[\u2029\u2028\n]/)
.reduce((acc, line) => {
if (line) {
acc.push(line);
}
return acc;
}, [])
.filter(line => !!line)
.join("\n");
}
return this[$content][$text]();
@ -5748,18 +5743,15 @@ class Text extends ContentObject {
.map(para =>
// Convert a paragraph into a set of <span> (for lines)
// separated by <br>.
para.split(/[\u2028\n]/).reduce((acc, line) => {
acc.push(
{
name: "span",
value: line,
},
{
name: "br",
}
);
return acc;
}, [])
para.split(/[\u2028\n]/).flatMap(line => [
{
name: "span",
value: line,
},
{
name: "br",
},
])
)
.forEach(lines => {
html.children.push({