From 058e1bddf394a38cb3c4e60452450b5521d42d56 Mon Sep 17 00:00:00 2001 From: Brian Takita Date: Tue, 1 May 2018 21:28:37 -0400 Subject: [PATCH] Added key & rootKey into 'Cyclical dependency detected' error message --- store.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/store.js b/store.js index 678c73b1b3..abc2f1886f 100644 --- a/store.js +++ b/store.js @@ -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); } },