+32
-3
lines changedFilter options
+32
-3
lines changed Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import { parseHTML } from './html-parser'
5
5
import { parseText } from './text-parser'
6
6
import { parseFilters } from './filter-parser'
7
7
import { genAssignmentCode } from '../directives/model'
8
-
import { extend, cached, no, camelize } from 'shared/util'
8
+
import { extend, cached, no, camelize, hyphenate } from 'shared/util'
9
9
import { isIE, isEdge, isServerRendering } from 'core/util/env'
10
10
11
11
import {
@@ -524,7 +524,7 @@ function processComponent (el) {
524
524
525
525
function processAttrs (el) {
526
526
const list = el.attrsList
527
-
let i, l, name, rawName, value, modifiers, isProp
527
+
let i, l, name, rawName, value, modifiers, isProp, syncGen
528
528
for (i = 0, l = list.length; i < l; i++) {
529
529
name = rawName = list[i].name
530
530
value = list[i].value
@@ -558,11 +558,19 @@ function processAttrs (el) {
558
558
name = camelize(name)
559
559
}
560
560
if (modifiers.sync) {
561
+
syncGen = genAssignmentCode(value, `$event`)
561
562
addHandler(
562
563
el,
563
564
`update:${camelize(name)}`,
564
-
genAssignmentCode(value, `$event`)
565
+
syncGen
565
566
)
567
+
if (hyphenate(name) !== camelize(name)) {
568
+
addHandler(
569
+
el,
570
+
`update:${hyphenate(name)}`,
571
+
syncGen
572
+
)
573
+
}
566
574
}
567
575
}
568
576
if (isProp || (
Original file line number Diff line number Diff line change
@@ -166,6 +166,27 @@ describe('Directive v-bind', () => {
166
166
}).then(done)
167
167
})
168
168
169
+
it('.sync modifier with kebab case event', done => {
170
+
const vm = new Vue({
171
+
template: `<test :foo-bar.sync="bar"/>`,
172
+
data: {
173
+
bar: 1
174
+
},
175
+
components: {
176
+
test: {
177
+
props: ['fooBar'],
178
+
template: `<div @click="$emit('update:foo-bar', 2)">{{ fooBar }}</div>`
179
+
}
180
+
}
181
+
}).$mount()
182
+
183
+
expect(vm.$el.textContent).toBe('1')
184
+
triggerEvent(vm.$el, 'click')
185
+
waitForUpdate(() => {
186
+
expect(vm.$el.textContent).toBe('2')
187
+
}).then(done)
188
+
})
189
+
169
190
it('bind object', done => {
170
191
const vm = new Vue({
171
192
template: '<input v-bind="test">',
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4