This commit is contained in:
harttle
2017-04-17 22:49:53 +08:00
parent cc2b2ea5d1
commit 2d793a63fe
2 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -129,7 +129,7 @@ var Scope = {
name = str.slice(i + 2, j); name = str.slice(i + 2, j);
seq.push(name); seq.push(name);
name = ''; name = '';
i = j + 1; i = j + 2;
} }
} }
// foo.bar // foo.bar
+7 -1
View File
@@ -30,12 +30,18 @@ describe('scope', function() {
expect(scope.propertyAccessSeq('foo[foo]')) expect(scope.propertyAccessSeq('foo[foo]'))
.to.deep.equal(['foo', 'zoo']); .to.deep.equal(['foo', 'zoo']);
}); });
it('should handle nested access', function() { it('should handle nested access 1', function() {
expect(scope.propertyAccessSeq('foo[bar.zoo]')) expect(scope.propertyAccessSeq('foo[bar.zoo]'))
.to.deep.equal(['foo', 'coo']); .to.deep.equal(['foo', 'coo']);
});
it('should handle nested access 2', function() {
expect(scope.propertyAccessSeq('foo[bar["zoo"]]')) expect(scope.propertyAccessSeq('foo[bar["zoo"]]'))
.to.deep.equal(['foo', 'coo']); .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() { describe('#get()', function() {