Skip to content

Commit 903223a

Browse files
committed
also test dynamic get
1 parent 26c9255 commit 903223a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/api/data.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var _ = require('../util')
21
var Watcher = require('../watcher')
32
var Path = require('../parsers/path')
43
var textParser = require('../parsers/text')

src/parsers/expression.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ function compilePathFns (exp) {
146146
if (exp.indexOf('[') < 0) {
147147
// really simple path
148148
path = exp.split('.')
149+
path.raw = exp
149150
getter = Path.compileGetter(path)
150151
} else {
151152
// do the real parsing

test/unit/specs/parsers/path_spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ describe('Path Parser', function () {
8585
expect(Path.get(obj, 'a.c')).toBeUndefined()
8686
})
8787

88+
it('get dynamic', function () {
89+
var path = 'a[b]'
90+
var obj = {
91+
a: {
92+
key: 123
93+
},
94+
b: 'key'
95+
}
96+
expect(Path.get(obj, path)).toBe(123)
97+
})
98+
8899
it('set', function () {
89100
var path = 'a.b.c'
90101
var obj = {

0 commit comments

Comments
 (0)