File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
test/unit/features/directives Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ export function genComponentModel (
1515 if ( trim ) {
1616 valueExpression =
1717 `(typeof ${ baseValueExpression } === 'string'` +
18- `? ${ baseValueExpression } .trim()` +
19- `: ${ baseValueExpression } )`
18+ `? ${ baseValueExpression } .trim()` +
19+ `: ${ baseValueExpression } )`
2020 }
2121 if ( number ) {
2222 valueExpression = `_n(${ valueExpression } )`
@@ -68,6 +68,9 @@ type ModelParseResult = {
6868}
6969
7070export function parseModel ( val : string ) : ModelParseResult {
71+ // Fix https://github.com/vuejs/vue/pull/7730
72+ // allow v-model="obj.val " (trailing whitespace)
73+ val = val . trim ( )
7174 len = val . length
7275
7376 if ( val . indexOf ( '[' ) < 0 || val . lastIndexOf ( ']' ) < len - 1 ) {
Original file line number Diff line number Diff line change @@ -19,6 +19,21 @@ describe('Directive v-model text', () => {
1919 } ) . then ( done )
2020 } )
2121
22+ it ( 'should work with space ended expression in v-model' , ( ) => {
23+ const vm = new Vue ( {
24+ data : {
25+ obj : {
26+ test : 'b'
27+ }
28+ } ,
29+ template : '<input v-model="obj.test ">'
30+ } ) . $mount ( )
31+
32+ triggerEvent ( vm . $el , 'input' )
33+ expect ( vm . obj [ 'test ' ] ) . toBe ( undefined )
34+ expect ( vm . obj . test ) . toBe ( 'b' )
35+ } )
36+
2237 it ( '.lazy modifier' , ( ) => {
2338 const vm = new Vue ( {
2439 data : {
You can’t perform that action at this time.
0 commit comments