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