File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
test/unit/features/directives Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ export function parseModel (val: string): Object {
116116 len = str . length
117117 index = expressionPos = expressionEndPos = 0
118118
119- if ( val . indexOf ( '[' ) < 0 ) {
119+ if ( val . indexOf ( '[' ) < 0 || val . lastIndexOf ( ']' ) < len - 1 ) {
120120 return {
121121 exp : val ,
122122 idx : null
Original file line number Diff line number Diff line change 11import { parseModel } from 'compiler/helpers'
22
33describe ( 'model expression parser' , ( ) => {
4+ it ( 'parse object dot notation' , ( ) => {
5+ const res = parseModel ( 'a.b.c' )
6+ expect ( res . exp ) . toBe ( 'a.b.c' )
7+ expect ( res . idx ) . toBe ( null )
8+ } )
9+
410 it ( 'parse string in brackets' , ( ) => {
511 const res = parseModel ( 'a["b"][c]' )
612 expect ( res . exp ) . toBe ( 'a["b"]' )
713 expect ( res . idx ) . toBe ( 'c' )
814 } )
915
16+ it ( 'parse brackets with object dot notation' , ( ) => {
17+ const res = parseModel ( 'a["b"][c].xxx' )
18+ expect ( res . exp ) . toBe ( 'a["b"][c].xxx' )
19+ expect ( res . idx ) . toBe ( null )
20+ } )
21+
1022 it ( 'parse nested brackets' , ( ) => {
1123 const res = parseModel ( 'a[i[c]]' )
1224 expect ( res . exp ) . toBe ( 'a' )
You can’t perform that action at this time.
0 commit comments