You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/05/12 11:38:03 UTC

[GitHub] [echarts] pissang commented on a change in pull request #14905: fix(tree): error when running setOption twice with diff data

pissang commented on a change in pull request #14905:
URL: https://github.com/apache/echarts/pull/14905#discussion_r630961408



##########
File path: src/chart/tree/TreeSeries.ts
##########
@@ -149,7 +149,7 @@ class TreeSeriesModel extends SeriesModel<TreeSeriesOption> {
         function beforeLink(nodeData: List) {
             nodeData.wrapMethod('getItemModel', function (model, idx) {
                 const node = tree.getNodeByDataIndex(idx);
-                if (!node.children.length || !node.isExpand) {
+                if (!node?.children.length || !node.isExpand) {

Review comment:
       We avoid using optional chaining in our code because it is easy to generate lots of unnecessary code after compiled.
   ```ts
   if (!(node && node.children.length && node.isExpand))
   ``` 
    will be much simpler here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org