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

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

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

Loading…
Cancel
Save