From 3dc37bf980a29649d0aa875813a340503e0b8f92 Mon Sep 17 00:00:00 2001 From: jaswrks Date: Wed, 2 Aug 2017 10:37:11 -0800 Subject: [PATCH] Bug fix for `foo.bar[0].foo` that is not working. Corrects a bug where `foo.bar[0].foo` results in error: 'Cannot read property `foo` of undefined', because the sequence contains an empty string; i.e., `seq.push('')` should be avoided. Another possible solution would be to strip empty strings from the final `seq` variable, but this PR fixes the immediate problem. --- src/scope.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/scope.js b/src/scope.js index 77f843d3f..a65cc32c1 100644 --- a/src/scope.js +++ b/src/scope.js @@ -131,7 +131,10 @@ var Scope = { } } else if (str[i] === '.') { // foo.bar - seq.push(name) + // foo.bar[0].foo + // In the case of foo.bar[0].foo, must check length because + // name will be empty after the closing `]` is handled above. + if (name.length) seq.push(name) name = '' } else { // foo.bar