mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
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:
+4
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user