提交 a4cbf5bb 编写于 作者: P pah100

Throw error when encount circle in topology travel.

上级 a54f73c1
......@@ -212,7 +212,7 @@ define(function(require) {
*
* If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology.
*
* If there are circle dependenceis, just ignore them.
* If there is circle dependencey, Error will be thrown.
*
*/
util.enableTopologicalTravel = function (entity, dependencyGetter) {
......@@ -244,10 +244,15 @@ define(function(require) {
var currVertex = graph[currComponentType];
if (targetNameSet[currComponentType]) {
callback.call(context, currComponentType, currVertex.originalDeps.slice());
delete targetNameSet[currComponentType];
}
zrUtil.each(currVertex.successor, removeEdge);
}
zrUtil.each(targetNameSet, function () {
throw new Error('Circle dependency may exists');
});
function removeEdge(succComponentType) {
graph[succComponentType].entryCount--;
if (graph[succComponentType].entryCount === 0) {
......
......@@ -85,14 +85,9 @@ describe('Component', function() {
ComponentModel.extend({type: 'a2'});
ComponentModel.extend({type: 'a3'});
var allList = ComponentModel.getAllClassMainTypes();
var result = [];
ComponentModel.topologicalTravel(['m1', 'm2', 'a1', 'a2'], allList, function (componentType, dependencies) {
result.push([componentType, dependencies]);
});
expect(result).toEqual([['a2', []]]);
// expect(function () {
// ComponentModel.topologicalTravel(['m1', 'm2', 'a1'], allList);
// }).toThrowError(/Circl/);
expect(function () {
ComponentModel.topologicalTravel(['m1', 'm2', 'a1'], allList);
}).toThrowError(/Circl/);
});
testCase('topologicalTravel_multipleEchartsInstance', function (ComponentModel) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册