File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
src/core/instance/render-helpers
test/unit/features/directives Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 66 warn ,
77 isObject ,
88 toObject ,
9- isReservedAttribute
9+ isReservedAttribute ,
10+ camelize
1011} from 'core/util/index'
1112
1213/**
@@ -43,12 +44,13 @@ export function bindObjectProps (
4344 ? data . domProps || ( data . domProps = { } )
4445 : data . attrs || ( data . attrs = { } )
4546 }
46- if ( ! ( key in hash ) ) {
47+ const camelizedKey = camelize ( key )
48+ if ( ! ( key in hash ) && ! ( camelizedKey in hash ) ) {
4749 hash [ key ] = value [ key ]
4850
4951 if ( isSync ) {
5052 const on = data . on || ( data . on = { } )
51- on [ `update:${ key } ` ] = function ( $event ) {
53+ on [ `update:${ camelizedKey } ` ] = function ( $event ) {
5254 value [ key ] = $event
5355 }
5456 }
Original file line number Diff line number Diff line change @@ -187,6 +187,26 @@ describe('Directive v-bind', () => {
187187 } ) . then ( done )
188188 } )
189189
190+ it ( 'bind object with explicit overrides' , ( ) => {
191+ const vm = new Vue ( {
192+ template : `<test v-bind="test" data-foo="foo" dataBar="bar"/>` ,
193+ components : {
194+ test : {
195+ template : '<div :data-foo="dataFoo" :data-bar="dataBar"></div>' ,
196+ props : [ 'dataFoo' , 'dataBar' ]
197+ }
198+ } ,
199+ data : {
200+ test : {
201+ dataFoo : 'hi' ,
202+ dataBar : 'bye'
203+ }
204+ }
205+ } ) . $mount ( )
206+ expect ( vm . $el . getAttribute ( 'data-foo' ) ) . toBe ( 'foo' )
207+ expect ( vm . $el . getAttribute ( 'data-bar' ) ) . toBe ( 'bar' )
208+ } )
209+
190210 it ( '.sync modifier with bind object' , done => {
191211 const vm = new Vue ( {
192212 template : `<test v-bind.sync="test"/>` ,
You can’t perform that action at this time.
0 commit comments