You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2020/10/14 08:10:13 UTC
[incubator-echarts] 03/08: fix: fix that throw error if only a few
components mounted.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch fix-ut
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit 4d7f549d94fa1e660a60734d578af3c294817310
Author: 100pah <su...@gmail.com>
AuthorDate: Tue Oct 13 01:20:46 2020 +0800
fix: fix that throw error if only a few components mounted.
---
src/model/Global.ts | 6 ++++--
src/util/component.ts | 15 ++++++++++-----
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/model/Global.ts b/src/model/Global.ts
index b1f5dfb..0b97c8d 100644
--- a/src/model/Global.ts
+++ b/src/model/Global.ts
@@ -258,7 +258,7 @@ class GlobalModel extends Model<ECUnitOption> {
// (1) for normal merge, `{xxx: null/undefined}` are the same meaning as `{xxx: []}`.
// (2) some preprocessor may convert some of `{xxx: null/undefined}` to `{xxx: []}`.
replaceMergeMainTypeMap.each(function (val, mainTypeInReplaceMerge) {
- if (!newCmptTypeMap.get(mainTypeInReplaceMerge)) {
+ if (ComponentModel.hasClass(mainTypeInReplaceMerge) && !newCmptTypeMap.get(mainTypeInReplaceMerge)) {
newCmptTypes.push(mainTypeInReplaceMerge);
newCmptTypeMap.set(mainTypeInReplaceMerge, true);
}
@@ -755,7 +755,9 @@ class GlobalModel extends Model<ECUnitOption> {
const componentsMap = this._componentsMap;
const componentTypes: string[] = [];
componentsMap.each(function (components, componentType) {
- componentTypes.push(componentType);
+ if (ComponentModel.hasClass(componentType)) {
+ componentTypes.push(componentType);
+ }
});
(ComponentModel as ComponentModelConstructor).topologicalTravel(
diff --git a/src/util/component.ts b/src/util/component.ts
index 0c3e7c5..5433337 100644
--- a/src/util/component.ts
+++ b/src/util/component.ts
@@ -21,6 +21,7 @@ import * as zrUtil from 'zrender/src/core/util';
import {parseClassType, ClassManager} from './clazz';
import { ComponentOption, ComponentMainType, ComponentSubType, ComponentFullType } from './types';
import { Dictionary } from 'zrender/src/core/types';
+import { makePrintable } from './log';
// A random offset
let base = Math.round(Math.random() * 10);
@@ -127,15 +128,15 @@ export function enableTopologicalTravel<T>(
const result = makeDepndencyGraph(fullNameList);
const graph = result.graph;
- const stack = result.noEntryList;
+ const noEntryList = result.noEntryList;
const targetNameSet: {[cmtpMainType: string]: boolean} = {};
zrUtil.each(targetNameList, function (name) {
targetNameSet[name] = true;
});
- while (stack.length) {
- const currComponentType = stack.pop();
+ while (noEntryList.length) {
+ const currComponentType = noEntryList.pop();
const currVertex = graph[currComponentType];
const isInTargetNameSet = !!targetNameSet[currComponentType];
if (isInTargetNameSet) {
@@ -149,13 +150,17 @@ export function enableTopologicalTravel<T>(
}
zrUtil.each(targetNameSet, function () {
- throw new Error('Circle dependency may exists');
+ let errMsg = '';
+ if (__DEV__) {
+ errMsg = makePrintable('Circle dependency may exists: ', targetNameSet, targetNameList, fullNameList);
+ }
+ throw new Error(errMsg);
});
function removeEdge(succComponentType: ComponentMainType): void {
graph[succComponentType].entryCount--;
if (graph[succComponentType].entryCount === 0) {
- stack.push(succComponentType);
+ noEntryList.push(succComponentType);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org