Skip to content

Commit 67e8b9e

Browse files
JustineoLostlover
authored andcommitted
fix: v-bind object should be overridable by single bindings (vuejs#9653)
fix vuejs#9641
1 parent b5c2f7d commit 67e8b9e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/core/instance/render-helpers/bind-object-props.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
isObject,
88
toObject,
99
isReservedAttribute,
10-
camelize
10+
camelize,
11+
hyphenate
1112
} from 'core/util/index'
1213

1314
/**
@@ -45,12 +46,13 @@ export function bindObjectProps (
4546
: data.attrs || (data.attrs = {})
4647
}
4748
const camelizedKey = camelize(key)
48-
if (!(key in hash) && !(camelizedKey in hash)) {
49+
const hyphenatedKey = hyphenate(key)
50+
if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
4951
hash[key] = value[key]
5052

5153
if (isSync) {
5254
const on = data.on || (data.on = {})
53-
on[`update:${camelizedKey}`] = function ($event) {
55+
on[`update:${key}`] = function ($event) {
5456
value[key] = $event
5557
}
5658
}

test/unit/features/directives/bind.spec.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ describe('Directive v-bind', () => {
234234
template: `<test v-bind="test" data-foo="foo" dataBar="bar"/>`,
235235
components: {
236236
test: {
237-
template: '<div :data-foo="dataFoo" :data-bar="dataBar"></div>',
237+
template: '<div>{{ dataFoo }} {{ dataBar }}</div>',
238238
props: ['dataFoo', 'dataBar']
239239
}
240240
},
@@ -245,8 +245,7 @@ describe('Directive v-bind', () => {
245245
}
246246
}
247247
}).$mount()
248-
expect(vm.$el.getAttribute('data-foo')).toBe('foo')
249-
expect(vm.$el.getAttribute('data-bar')).toBe('bar')
248+
expect(vm.$el.textContent).toBe('foo bar')
250249
})
251250

252251
it('.sync modifier with bind object', done => {

0 commit comments

Comments
 (0)