Bug in js\spreadsheet\numformat.js makeDateFormat
You appear to be using the wrong indices inside a nested loop.
if (/^(?:date|time|ampm)$/.test(section.body[i].type)) {
Should be (switch i to j)
if (/^(?:date|time|ampm)$/.test(section.body[j].type)) {
Getting error
Uncaught TypeError: Cannot read property 'type' of undefined
at Object.<anonymous> (numformat.js:630)
Note: Version is actually 2018.3.1114 from npm
for
(
var
i = 0; i < tree.length; ++i) {
section = tree[i];
for
(
var
j = 0; j < section.body.length; ++j) {
if
(/^(?:date|time|ampm)$/.test(section.body[j].type)) {
found =
true
;
if
(section.body[j].type ==
"ampm"
) {
hasAmpm =
true
;
}
Hi Misho,
Thanks for getting back to me. It'll take quite a bit of work on our side to produce a stripped down sample of this. Instead here is the patch that we've applied to continue using the spreadsheets. As you can see by simply looking at the loops, any time the tree length is greater than the section body length there will be an error as the section body index is incorrect.
patch-package
--- a/node_modules/@progress/kendo-ui/js/spreadsheet/numformat.js
+++ b/node_modules/@progress/kendo-ui/js/spreadsheet/numformat.js
@@ -627,7 +627,7 @@ module.exports =
for (var i = 0; i < tree.length; ++i) {
section = tree[i];
for (var j = 0; j < section.body.length; ++j) {
- if (/^(?:date|time|ampm)$/.test(section.body[i].type)) {
+ if (/^(?:date|time|ampm)$/.test(section.body[j].type)) {
found = true;
if (section.body[i].type == "ampm") {
hasAmpm = true;