Skip to content

Commit

Permalink
fix(custom): fix potential NPE when applying leave transition.
Browse files Browse the repository at this point in the history
  • Loading branch information
plainheart committed Jul 4, 2022
1 parent 731362b commit 70b10e1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 30 deletions.
10 changes: 5 additions & 5 deletions src/chart/custom/CustomView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export default class CustomChartView extends ChartView {
})
.remove(function (oldIdx) {
const el = oldData.getItemGraphicEl(oldIdx);
applyLeaveTransition(el, customInnerStore(el).option, customSeries);
el && applyLeaveTransition(el, customInnerStore(el).option, customSeries);
})
.update(function (newIdx, oldIdx) {
const oldEl = oldData.getItemGraphicEl(oldIdx);
Expand Down Expand Up @@ -1326,11 +1326,11 @@ function mergeChildren(
);
}
for (let i = el.childCount() - 1; i >= index; i--) {
// Do not supprot leave elements that are not mentioned in the latest
// Do not support leave elements that are not mentioned in the latest
// `renderItem` return. Otherwise users may not have a clear and simple
// concept that how to contorl all of the elements.
// concept that how to control all of the elements.
const child = el.childAt(i);
applyLeaveTransition(child, customInnerStore(el).option, seriesModel);
child && applyLeaveTransition(child, customInnerStore(el).option, seriesModel);
}
}

Expand Down Expand Up @@ -1383,7 +1383,7 @@ function processAddUpdate(
function processRemove(this: DataDiffer<DiffGroupContext>, oldIndex: number): void {
const context = this.context;
const child = context.oldChildren[oldIndex];
applyLeaveTransition(child, customInnerStore(child).option, context.seriesModel);
child && applyLeaveTransition(child, customInnerStore(child).option, context.seriesModel);
}

/**
Expand Down
73 changes: 50 additions & 23 deletions test/custom.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/runTest/actions/__meta__.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 70b10e1

Please sign in to comment.