File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ const newlineRE = /\n/g
26
26
const saveRE = / [ \{ , ] \s * [ \w \$ _ ] + \s * : | ( ' (?: [ ^ ' \\ ] | \\ .) * ' | " (?: [ ^ " \\ ] | \\ .) * " ) | n e w | t y p e o f | v o i d / g
27
27
const restoreRE = / " ( \d + ) " / g
28
28
const pathTestRE = / ^ [ A - Z a - z _ $ ] [ \w $ ] * (?: \. [ A - Z a - z _ $ ] [ \w $ ] * | \[ ' .* ?' \] | \[ " .* ?" \] | \[ \d + \] | \[ [ A - Z a - z _ $ ] [ \w $ ] * \] ) * $ /
29
- const pathReplaceRE = / [ ^ \w $ \. ] (?: [ A - Z a - z _ $ ] [ \w $ ] * (?: \. [ A - Z a - z _ $ ] [ \w $ ] * | \[ ' . * ? ' \] | \[ " . * ? " \] ) * ) / g
29
+ const identRE = / [ ^ \w $ \. ] (?: [ A - Z a - z _ $ ] [ \w $ ] * ) / g
30
30
const booleanLiteralRE = / ^ (?: t r u e | f a l s e ) $ /
31
31
32
32
/**
@@ -119,7 +119,7 @@ function compileGetter (exp) {
119
119
// rewrite all paths
120
120
// pad 1 space here becaue the regex matches 1 extra char
121
121
body = ( ' ' + body )
122
- . replace ( pathReplaceRE , rewrite )
122
+ . replace ( identRE , rewrite )
123
123
. replace ( restoreRE , restore )
124
124
return makeGetterFn ( body )
125
125
}
Original file line number Diff line number Diff line change @@ -181,6 +181,18 @@ var testCases = [
181
181
expected : "a\'b\'c" ,
182
182
paths : [ 'c' ]
183
183
} ,
184
+ {
185
+ // dynamic sub path
186
+ exp : "a['b' + i + 'c']" ,
187
+ scope : {
188
+ i : 0 ,
189
+ a : {
190
+ 'b0c' : 123
191
+ }
192
+ } ,
193
+ expected : 123 ,
194
+ paths : [ 'a' , 'i' ]
195
+ } ,
184
196
{
185
197
// Math global, simple path
186
198
exp : 'Math.PI' ,
You can’t perform that action at this time.
0 commit comments