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/03/08 02:17:52 UTC

[GitHub] [echarts] pissang commented on a change in pull request #14413: fix(series): fix series data type judgment bug. close #14293

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



##########
File path: src/model/Series.ts
##########
@@ -575,8 +575,8 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
         if (data.hasItemOption) {
             data.each(function (idx) {
                 const rawItem = data.getRawDataItem(idx);
-                if (typeof rawItem === 'object'
-                    && (rawItem as OptionDataItemObject<unknown>).selected
+                if (zrUtil.isObject(rawItem)
+                    && (rawItem as OptionDataItemObject<unknown>)?.selected

Review comment:
       Optional chaining will be transpiled to
   ```js
   rawItem === null || rawItem === void 0 ? void 0 : rawItem.selected;
   ```
   and brings extra codes in the final distribution.
   
   So we limited the use of optional chaining in echarts to keep the distribution as small as possible.
   
   Instead 
   ```ts
   (rawItem && (rawItem as OptionDataItemObject<unknown>).selected)
   ```
   is enough 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