I’ve worked out an alternate way to get the correct label text, but have not (yet!) uploaded the fixed TWs.
I still don’t know exactly what’s going on, but it appears the filter string I use to extract the label text: “[<context>jsonget[chart],[data],[datasets],<di>,[label]]” is failing when it gets to the “[data]” part. The only clue I have is that when I inspect the relevant object hierarchy in the browser Inspector, the “data” property is faded, which by Googling seems to indicate the property is not enumerable. This is also the case in 5.3.0 (which works), so maybe a property check of some sort has been added?
Thanks. That looked like it could have been it. “[data]” is an “object”, not a “number”, “string”, or “boolean”. Having said that, the “[chart]” part is also an object. I set a breakpoint on the “item = undefined” and it didn’t trip…
Found the change:
in getItemAtIndex() where item is the chart object and index is “data”. The hop() call fails and “data” isn’t an array, so it returns undefined.
However, the change I’ve found isn’t the change that introduced the call to hop(). I’m still looking…
I’ve already found a workaround for my use case. Since this involves accessing third-party JS object hierarchies, it’s probably not worth holding up the 5.3.4 release. It’s been around since the current 5.3.3 release anyway.
The change I found was it. Specifically the change in getDataItem() from
item = item[indexes[i]];
to
item = getItemAtIndex(item,indexes[i]);
I wonder if getItemAtIndex() should drop the call to hop():
function getItemAtIndex(item,index) {
if($tw.utils.isArray(item)) {
index = $tw.utils.parseInt(index);
if(index < 0) { index = index + item.length };
}
return item[index]; // Will be undefined if index was out-of-bounds
}
?
I can try to contrive a test case, but that will have to be tomorrow. It’s way after my bedtime here…
I don’t think so. I asked about this before. @jeremyruston thought it might be a good idea, but his answer also made it clear that it wouldn’t be as useful as I would have hoped, and I didn’t follow up. I haven’t heard about any further progress.
As @Scott_Sauyet says, there are only the empty and full versions, no upgrader. I was going to try upgrading in steps from 5.3.0 to narrow down the problem, but @saqimtiaz turned up and basically pointed me at it. (aside: from the date of the change it was introduced in 5.3.2).
Also, I can confirm that the change to getItemAtIndex() that I’ve suggested fixes the issue for me. If you really wanted to keep the hop() in there, then the following also works:
function getItemAtIndex(item,index) {
if(!$tw.utils.hop(item,index) && $tw.utils.isArray(item)) {
index = $tw.utils.parseInt(index);
if(index < 0) { index = index + item.length };
}
return item[index];
}