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.
This commit is contained in:
jaswrks
2017-08-02 10:37:11 -08:00
committed by GitHub
parent 4ee2bc964c
commit 3dc37bf980
+4 -1
View File
@@ -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