New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(series): fix series data type judgment bug. close #14293 #14413
Conversation
Thanks for your contribution! |
src/model/Series.ts
Outdated
if (typeof rawItem === 'object' | ||
&& (rawItem as OptionDataItemObject<unknown>).selected | ||
if (zrUtil.isObject(rawItem) | ||
&& (rawItem as OptionDataItemObject<unknown>)?.selected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional chaining will be transpiled to
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
(rawItem && (rawItem as OptionDataItemObject<unknown>).selected)
is enough here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use zrUtil.isObject(rawItem) replace in here may be more safe?@pissang
src/model/Series.ts
Outdated
@@ -575,8 +575,7 @@ 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 (rawItem && (rawItem as OptionDataItemObject<unknown>).selected | |||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to newline here for a better code style.
if (rawItem && (rawItem as OptionDataItemObject<unknown>).selected) {
@@ -0,0 +1,693 @@ | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not be committed
Congratulations! Your PR has been merged. Thanks for your contribution! |
Brief Information
fix series data type judgment bug
This pull request is in the type of:
What does this PR do?
fix series data type judgment bug, typeof null === "object"
Fixed issues
#14293
Details
when set
Before: What was the problem?
when rawItem is null, get prop selected error
After: How is it fixed in this PR?
Usage
Are there any API changes?
Related test cases or examples to use the new APIs
test/line-non-continuous.html
Others
Merging options
Other information