8000 add .camel modifier for v-bind (workaround for #2250) · codeclever/vue@ad7585f · GitHub
[go: up one dir, main page]

Skip to content

Commit ad7585f

Browse files
committed
add .camel modifier for v-bind (workaround for vuejs#2250)
1 parent 20deeee commit ad7585f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/directives/public/bind.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { warn, setClass } from '../../util/index'
1+
import { warn, setClass, camelize } from '../../util/index'
22
import { BIND } from '../priorities'
33
import vStyle from '../internal/style'
44
import { tokensToExp } from '../../parsers/text'
@@ -96,6 +96,9 @@ export default {
9696
handleSingle (attr, value) {
9797
const el = this.el
9898
const interp = this.descriptor.interp
99+
if (this.modifiers.camel) {
100+
attr = camelize(attr)
101+
}
99102
if (
100103
!interp &&
101104
attrWithPropsRE.test(attr) &&

test/unit/specs/directives/public/bind_spec.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ describe('v-bind', function () {
99
el = document.createElement('div')
1010
dir = {
1111
el: el,
12-
descriptor: {}
12+
descriptor: {},
13+
modifiers: {}
1314
}
1415
_.extend(dir, def)
1516
})
@@ -70,4 +71,14 @@ describe('v-bind', function () {
7071
dir.update(null)
7172
expect(dir.el.hasAttributeNS(xlinkNS, 'special')).toBe(false)
7273
})
74+
75+
it('camel modifier', function () {
76+
dir.modifiers.camel = true
77+
var div = document.createElement('div')
78+
div.innerHTML = '<svg></svg>'
79+
dir.el = div.children[0]
80+
dir.arg = 'view-box'
81+
dir.update('0 0 1500 1000')
82+
expect(dir.el.getAttribute('viewBox')).toBe('0 0 1500 1000')
83+
})
7384
})

0 commit comments

Comments
 (0)
0