diff --git a/src/scope.js b/src/scope.js index 3edea618e..109c9c78c 100644 --- a/src/scope.js +++ b/src/scope.js @@ -129,7 +129,7 @@ var Scope = { name = str.slice(i + 2, j); seq.push(name); name = ''; - i = j + 1; + i = j + 2; } } // foo.bar diff --git a/test/scope.js b/test/scope.js index 0db65bcf2..28e4dea41 100644 --- a/test/scope.js +++ b/test/scope.js @@ -30,12 +30,18 @@ describe('scope', function() { expect(scope.propertyAccessSeq('foo[foo]')) .to.deep.equal(['foo', 'zoo']); }); - it('should handle nested access', function() { + it('should handle nested access 1', function() { expect(scope.propertyAccessSeq('foo[bar.zoo]')) .to.deep.equal(['foo', 'coo']); + }); + it('should handle nested access 2', function() { expect(scope.propertyAccessSeq('foo[bar["zoo"]]')) .to.deep.equal(['foo', 'coo']); }); + it('should handle nested access 3', function() { + expect(scope.propertyAccessSeq('bar["foo"].zoo')) + .to.deep.equal(['bar', 'foo', 'zoo']); + }); }); describe('#get()', function() {