Added key & rootKey into 'Cyclical dependency detected' error message

pull/1400/head
Brian Takita 6 years ago
parent 4d8090aa15
commit 058e1bddf3

@ -52,18 +52,20 @@ assign(Store.prototype, {
var cycles;
var visited = blankObject();
function visit(key) {
function visit(key, rootKey) {
if (visited[key]) return;
if (cycles[key]) {
throw new Error('Cyclical dependency detected');
throw new Error('Cyclical dependency detected. key: ' + key + ' rootKey: ' + rootKey);
}
var c = computed[key];
if (c) {
cycles[key] = true;
c.deps.forEach(visit);
c.deps.forEach(function(dep) {
visit(dep, rootKey)
});
sorted.push(c);
visited[key] = true;
}
@ -71,7 +73,7 @@ assign(Store.prototype, {
for (var key in this._computed) {
cycles = blankObject();
visit(key);
visit(key, key);
}
},

Loading…
Cancel
Save